{"id":43698,"library":"pretty-data2","title":"pretty-data2","description":"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.","status":"active","version":"0.40.1","language":"javascript","source_language":"en","source_url":"http://github.com/vkiryukhin/pretty-data","tags":["javascript","pretty print","beautify","minify","XML","JSON","CSS","SQL"],"install":[{"cmd":"npm install pretty-data2","lang":"bash","label":"npm"},{"cmd":"yarn add pretty-data2","lang":"bash","label":"yarn"},{"cmd":"pnpm add pretty-data2","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM import works; CommonJS require works but not recommended.","wrong":"const pd = require('pretty-data2')","symbol":"pd","correct":"import { pd } from 'pretty-data2'"},{"note":"Default export is not available; use named import or import submodule.","wrong":"import pd from 'pretty-data2'","symbol":"pd (default)","correct":"import pd from 'pretty-data2/pd'"},{"note":"Second argument preserves comments in XML minification.","wrong":"const pd = require('pretty-data2'); pd.xmlmin(data);","symbol":"pd.xmlmin","correct":"const { pd } = require('pretty-data2'); pd.xmlmin(data, true);"}],"quickstart":{"code":"import { pd } from 'pretty-data2';\n\nconst jsonData = '{\"name\":\"John\",\"age\":30,\"city\":\"New York\"}';\nconst prettyJson = pd.json(jsonData);\nconsole.log(prettyJson);\n\nconst xmlData = '<root><item id=\"1\">Hello</item></root>';\nconst prettyXml = pd.xml(xmlData);\nconsole.log(prettyXml);\n\nconst cssData = 'body{color:red;font-size:12px}';\nconst minCss = pd.cssmin(cssData);\nconsole.log(minCss);\n\nconst sqlData = 'SELECT * FROM users WHERE id = 1';\nconst prettySql = pd.sql(sqlData);\nconsole.log(prettySql);","lang":"typescript","description":"Demonstrates pretty-printing JSON, XML, SQL, and minifying CSS using pretty-data2 with ESM imports."},"warnings":[{"fix":"Use named import: import { pd } from 'pretty-data2'; or CommonJS: const pd = require('pretty-data2').pd;","message":"Default export not available; must use named import { pd } or require with property.","severity":"gotcha","affected_versions":">=0.40.0"},{"fix":"Call pd.xmlmin(data, true) to preserve comments, pd.xmlmin(data) to remove them.","message":"XML minification preserveComments parameter is boolean; passing true preserves comments, default false removes them.","severity":"gotcha","affected_versions":">=0.40.0"},{"fix":"Ensure correct import: import { pd } from 'pretty-data2'.","message":"The package is case-insensitive for method names but not for imports; wrong import path may lead to undefined.","severity":"gotcha","affected_versions":">=0.40.0"},{"fix":"Replace 'pretty-data' with 'pretty-data2' in your dependencies.","message":"The original 'pretty-data' package is unmaintained; 'pretty-data2' is the updated fork.","severity":"deprecated","affected_versions":">=0.40.0"}],"env_vars":null,"search_vec":"'0.40.1':23 'altern':67 'beautif':35 'beautifi':71,89 'build':63 'comment':44 'correspond':37 'css':15,49,93 'data':57 'data2':3 'depend':53 'differenti':65 'focus':75 'format':56,80 'four':79 'function':28 'infrequ':25 'javascript':86 'js':70 'js-beautifi':69 'json':14,92 'lightweight':50 'like':29,68 'method':85 'min':38 'minif':41,84 'minifi':12,90 'node.js':5 'offer':82 'option':43 'pd.css':32 'pd.json':31 'pd.sql':33 'pd.xml':30 'plugin':6 'preserv':45 'pretti':2,9,87 'prettier':73 'pretty-data2':1 'pretty-print':8 'print':10,88 'provid':27 'separ':83 'server':60 'sole':76 'sql':17,94 'stabl':21 'suitabl':54 'text':18 'tool':64 'updat':26 'variant':39 'version':22 'xml':13,47,91","created_at":"2026-06-05T17:01:03.595404+00:00","updated_at":"2026-06-05T17:01:03.595404+00:00","problems":[{"fix":"Use import { pd } from 'pretty-data2' or const pd = require('pretty-data2').pd;","cause":"Imported default export instead of named export, or used wrong import pattern.","error":"TypeError: pd.json is not a function"},{"fix":"Run: npm install pretty-data2","cause":"Package not installed or misspelled.","error":"Cannot find module 'pretty-data2'"},{"fix":"Validate input data before processing with pd.json() or pd.jsonmin().","cause":"Input data is not valid JSON/XML/CSS/SQL, or minification removed required quotes.","error":"SyntaxError: Unexpected token '}'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/vkiryukhin/pretty-data","github":"http://github.com/vkiryukhin/pretty-data","docs":null,"changelog":null,"pypi":null,"npm":"pretty-data2","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}