Registry / serialization / PrettyCSS

PrettyCSS

JSON →
library0.3.19jsnpmunverified

PrettyCSS is a CSS3-compliant parser, lint checker, and pretty printer for Node.js and browsers. It validates CSS property names and values, beautifies code to standard formats, and can minify styles. Version 0.3.19 (last release) has seen no updates since 2014; the project is in maintenance mode with no active development. It offers unique CSS3 support and thorough value validation compared to alternatives like CSSO or clean-css, but lacks modern features like PostCSS compatibility.

npm install PrettyCSS
INSTALL
IMPORT
SIG · PRETTYCSS
P
PrettyCSS
serializationjavascriptv0.3.19
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PrettyCSS
import PrettyCSS from 'prettycss';
const PrettyCSS = require('prettycss');
ESM default import; this package does not ship TypeScript types.
parse
import { parse } from 'prettycss';
import { parse as _ } from 'prettycss';
Named export (not default).
beautify
import { beautify } from 'prettycss';
import beautify from 'prettycss';
Named import, not default.

Parses a CSS file, lints it, and beautifies it with 2-space indentation.

import { parse, beautify, lint } from 'prettycss'; import fs from 'fs'; const css = fs.readFileSync('style.css', 'utf8'); const ast = parse(css, { source: 'style.css' }); const errors = lint(ast, { source: 'style.css' }); if (errors.length) { console.log('Lint errors:', errors); } const prettyCss = beautify(ast, { indent: ' ' }); fs.writeFileSync('pretty.css', prettyCss); console.log('Beautified CSS saved to pretty.css');
Debug
Known issues
gotchaThe package is unmaintained since 2014; no CSS4 or modern syntax support.
fix
Consider using a maintained alternative like PostCSS or stylelint.
affects: all
gotchaThe beautify function may produce invalid output for complex CSS (e.g., @supports, @container).
fix
Always verify output against a browser CSS parser.
affects: all
gotchaLint rules are hardcoded and cannot be extended; no configuration file.
fix
Use stylelint for customizable linting.
affects: all
Errors
Common errors & fixes
TypeError: PrettyCSS is not a constructor
Using CommonJS require() with ESM package.
fix
Use import PrettyCSS from 'prettycss'; or const PrettyCSS = require('prettycss').default;
SyntaxError: Unexpected token @
CSS contains modern syntax like @supports not supported by PrettyCSS.
fix
Pre-process CSS with a tool like PostCSS to strip unsupported rules, or avoid using modern syntax.
Cannot find module 'prettycss'
Package not installed or being used in an environment without proper module resolution.
fix
Run npm install prettycss and ensure the project uses CommonJS or ESM correctly.
Upgrade
Version history
0.3.19latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
72 hits · last 30 days
node
62
Amazon
1
OpenAI (training)
1
Resources
PrettyCSS — npm install PrettyCSS · libregistry