{"id":24877,"library":"PrettyCSS","title":"PrettyCSS","description":"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.","status":"maintenance","version":"0.3.19","language":"javascript","source_language":"en","source_url":"https://github.com/fidian/PrettyCSS","tags":["javascript","css","beautifier","pretty-printer","lint","validator"],"install":[{"cmd":"npm install PrettyCSS","lang":"bash","label":"npm"},{"cmd":"yarn add PrettyCSS","lang":"bash","label":"yarn"},{"cmd":"pnpm add PrettyCSS","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM default import; this package does not ship TypeScript types.","wrong":"const PrettyCSS = require('prettycss');","symbol":"PrettyCSS","correct":"import PrettyCSS from 'prettycss';"},{"note":"Named export (not default).","wrong":"import { parse as _ } from 'prettycss';","symbol":"parse","correct":"import { parse } from 'prettycss';"},{"note":"Named import, not default.","wrong":"import beautify from 'prettycss';","symbol":"beautify","correct":"import { beautify } from 'prettycss';"}],"quickstart":{"code":"import { parse, beautify, lint } from 'prettycss';\nimport fs from 'fs';\nconst css = fs.readFileSync('style.css', 'utf8');\nconst ast = parse(css, { source: 'style.css' });\nconst errors = lint(ast, { source: 'style.css' });\nif (errors.length) {\n  console.log('Lint errors:', errors);\n}\nconst prettyCss = beautify(ast, { indent: '  ' });\nfs.writeFileSync('pretty.css', prettyCss);\nconsole.log('Beautified CSS saved to pretty.css');","lang":"javascript","description":"Parses a CSS file, lints it, and beautifies it with 2-space indentation."},"warnings":[{"fix":"Consider using a maintained alternative like PostCSS or stylelint.","message":"The package is unmaintained since 2014; no CSS4 or modern syntax support.","severity":"gotcha","affected_versions":"all"},{"fix":"Always verify output against a browser CSS parser.","message":"The beautify function may produce invalid output for complex CSS (e.g., @supports, @container).","severity":"gotcha","affected_versions":"all"},{"fix":"Use stylelint for customizable linting.","message":"Lint rules are hardcoded and cannot be extended; no configuration file.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use import PrettyCSS from 'prettycss'; or const PrettyCSS = require('prettycss').default;","cause":"Using CommonJS require() with ESM package.","error":"TypeError: PrettyCSS is not a constructor"},{"fix":"Pre-process CSS with a tool like PostCSS to strip unsupported rules, or avoid using modern syntax.","cause":"CSS contains modern syntax like @supports not supported by PrettyCSS.","error":"SyntaxError: Unexpected token @"},{"fix":"Run npm install prettycss and ensure the project uses CommonJS or ESM correctly.","cause":"Package not installed or being used in an environment without proper module resolution.","error":"Cannot find module 'prettycss'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}