css-stringify

raw JSON →
2.0.0 verified Fri May 01 auth: no javascript maintenance

A JavaScript CSS stringifier for Node.js, part of the Rework CSS ecosystem. It takes an AST produced by css-parse and converts it back to a CSS string. Version 2.0.0 is the latest stable release, compatible with Node.js. Typically used internally via the `css` package. Not actively developed, but stable for legacy projects.

error TypeError: stringify is not a function
cause Using default import instead of named import.
fix
import { stringify } from 'css-stringify';
gotcha Package is deprecated in favor of the combined 'css' package. Direct usage is uncommon.
fix Use the 'css' package which re-exports stringify: import { stringify } from 'css';
npm install css-stringify
yarn add css-stringify
pnpm add css-stringify

Parses a CSS string to AST using css-parse, then stringifies it back to CSS using css-stringify.

import { stringify } from 'css-stringify';
import { parse } from 'css-parse';

const css = 'body { color: red; }';
const ast = parse(css);
const output = stringify(ast);
console.log(output); // prints: body { color: red; }