Registry / devops / pretty-data2

pretty-data2

JSON →
library0.40.1jsnpmunverified

A Node.js plugin for pretty-printing and minifying XML, JSON, CSS, and SQL text, with a stable version 0.40.1 and infrequent updates. Provides functions like pd.xml(), pd.json(), pd.css(), pd.sql() for beautification and corresponding *min variants for minification, with optional comment preservation for XML and CSS. Lightweight with no dependencies, suitable for formatting data on the server or in build tools. Differentiates from alternatives like js-beautify or prettier by focusing solely on these four formats and offering separate minification methods.

npm install pretty-data2
INSTALL
IMPORT
SIG · PRETTY-DATA2
P
pretty-data2
devopsjavascriptv0.40.1
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.

pd
import { pd } from 'pretty-data2'
const pd = require('pretty-data2')
ESM import works; CommonJS require works but not recommended.
pd (default)
import pd from 'pretty-data2/pd'
import pd from 'pretty-data2'
Default export is not available; use named import or import submodule.
pd.xmlmin
const { pd } = require('pretty-data2'); pd.xmlmin(data, true);
const pd = require('pretty-data2'); pd.xmlmin(data);
Second argument preserves comments in XML minification.

Demonstrates pretty-printing JSON, XML, SQL, and minifying CSS using pretty-data2 with ESM imports.

import { pd } from 'pretty-data2'; const jsonData = '{"name":"John","age":30,"city":"New York"}'; const prettyJson = pd.json(jsonData); console.log(prettyJson); const xmlData = '<root><item id="1">Hello</item></root>'; const prettyXml = pd.xml(xmlData); console.log(prettyXml); const cssData = 'body{color:red;font-size:12px}'; const minCss = pd.cssmin(cssData); console.log(minCss); const sqlData = 'SELECT * FROM users WHERE id = 1'; const prettySql = pd.sql(sqlData); console.log(prettySql);
Debug
Known issues
gotchaDefault export not available; must use named import { pd } or require with property.
fix
Use named import: import { pd } from 'pretty-data2'; or CommonJS: const pd = require('pretty-data2').pd;
affects: >=0.40.0
gotchaXML minification preserveComments parameter is boolean; passing true preserves comments, default false removes them.
fix
Call pd.xmlmin(data, true) to preserve comments, pd.xmlmin(data) to remove them.
affects: >=0.40.0
gotchaThe package is case-insensitive for method names but not for imports; wrong import path may lead to undefined.
fix
Ensure correct import: import { pd } from 'pretty-data2'.
affects: >=0.40.0
deprecatedThe original 'pretty-data' package is unmaintained; 'pretty-data2' is the updated fork.
fix
Replace 'pretty-data' with 'pretty-data2' in your dependencies.
affects: >=0.40.0
Errors
Common errors & fixes
TypeError: pd.json is not a function
Imported default export instead of named export, or used wrong import pattern.
fix
Use import { pd } from 'pretty-data2' or const pd = require('pretty-data2').pd;
Cannot find module 'pretty-data2'
Package not installed or misspelled.
fix
Run: npm install pretty-data2
SyntaxError: Unexpected token '}'
Input data is not valid JSON/XML/CSS/SQL, or minification removed required quotes.
fix
Validate input data before processing with pd.json() or pd.jsonmin().
Upgrade
Version history
0.40.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
pretty-data2 — npm install pretty-data2 · libregistry