A Node.js text formatting plugin for pretty-printing and minifying XML, JSON, CSS, and SQL. Version 0.1.4 is under active development with breaking changes expected. Forked from pretty-data, it offers synchronous and promise-based APIs, custom indentation via setStep(), and dual ESM/CJS support. Compared to alternatives like js-beautify, it covers SQL and XML natively and provides both beautify and minify functions in one package.
npm install sweet-dataNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates ESM and CJS imports, promise-based format/minify, setStep configuration, and error handling for JSON, XML, CSS.
Pin exact version and test upgrades thoroughly.
Use .then()/async-await to handle results.
Use named import: import { SweetData as sd } from 'sweet-data' or const sd = require('sweet-data').Review sweet-data docs; do not assume compatibility with pretty-data.
Pass true as second argument to preserve comments: sd.xmlmin(xml, true).
Ensure correct import: import { SweetData as sd } from 'sweet-data' (ESM) or const sd = require('sweet-data') (CJS).Verify input is a string (or object for json/jsonmin). For CSS/XML/SQL, input must be string.
Use appropriate function for the data format: sd.xml() for XML, sd.json() for JSON.
Use either ESM (import) or CJS (require) consistently.
No dependency data recorded yet.