PostCSS 8.2 added a new API to serialize and deserialize CSS AST to JSON.
import { parse, fromJSON } from 'postcss'
let root = parse('a{}', { from: 'input.css' })
let json = root.toJSON()
// save to file, send by network, etc
let root2 = fromJSON(json)