{"id":43697,"library":"pretty-data","title":"pretty-data","description":"A library for pretty-printing and minifying XML, JSON, CSS, and SQL strings. Version 0.40.0 is the latest stable release; no active development since 2016. Lightweight with zero dependencies, it provides simple functions for formatting and minifying common data formats. Unlike formatters specific to one format (e.g., js-beautify for JS/HTML/CSS), pretty-data handles multiple formats in a single package, but lacks tree-shaking and is not modular. ESM is not supported; only CommonJS.","status":"maintenance","version":"0.40.0","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-data","lang":"bash","label":"npm"},{"cmd":"yarn add pretty-data","lang":"bash","label":"yarn"},{"cmd":"pnpm add pretty-data","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Require-style only; library does not support ESM imports.","wrong":"import pd from 'pretty-data';","symbol":"prettyData (default import)","correct":"const pd = require('pretty-data');"},{"note":"XML functions are under pd.xml namespace.","wrong":"","symbol":"pd.xml","correct":"pd.xml.prettyPrint(xmlStr);\npd.xml.min(xmlStr);"},{"note":"Input must be a JSON string, not an object.","wrong":"JSON.parse then JSON.stringify with spacing; that's not minification.","symbol":"pd.json","correct":"pd.json.prettyPrint(jsonStr);\npd.json.min(jsonStr);"},{"note":"Both functions expect string input.","wrong":"Using pd.css.min on non-string input.","symbol":"pd.css","correct":"pd.css.prettyPrint(cssStr);\npd.css.min(cssStr);"},{"note":"SQL support is basic; may not handle all dialects.","wrong":"","symbol":"pd.sql","correct":"pd.sql.prettyPrint(sqlStr);\npd.sql.min(sqlStr);"}],"quickstart":{"code":"const pd = require('pretty-data');\n\nconst xml = '<root><child>data</child></root>';\nconsole.log(pd.xml.prettyPrint(xml));\n// Output:\n// <root>\n//   <child>data</child>\n// </root>\n\nconst json = '{\"name\":\"test\",\"value\":123}';\nconsole.log(pd.json.prettyPrint(json));\n// Output:\n// {\n//   \"name\": \"test\",\n//   \"value\": 123\n// }\n\nconsole.log(pd.json.min(json));\n// Output: {\"name\":\"test\",\"value\":123}\n\nconst css = 'body { color: red; font-size: 12px; }';\nconsole.log(pd.css.prettyPrint(css));\n// Output:\n// body {\n//   color: red;\n//   font-size: 12px;\n// }\n\nconst sql = 'SELECT * FROM users WHERE id = 1';\nconsole.log(pd.sql.prettyPrint(sql));\n// Output:\n// SELECT * FROM users\n// WHERE id = 1","lang":"javascript","description":"Demonstrates pretty-printing and minifying XML, JSON, CSS, and SQL using the library's CommonJS interface."},"warnings":[{"fix":"Ensure to convert objects to JSON strings using JSON.stringify before passing to pd.json functions.","message":"All functions expect a string input; passing an object will cause errors.","severity":"gotcha","affected_versions":"*"},{"fix":"Use require('pretty-data') instead of import.","message":"Library does not support ES module imports; using import will fail.","severity":"gotcha","affected_versions":"*"},{"fix":"Consider migrating to more actively maintained libraries like js-beautify for CSS/JSON or sql-formatter for SQL.","message":"The library has not been updated since 2016. No bug fixes or new features are expected.","severity":"deprecated","affected_versions":">=0.40.0"},{"fix":"If key sorting is needed, sort keys manually before pretty-printing.","message":"JSON prettyPrint does not sort keys; output order is based on input.","severity":"gotcha","affected_versions":"*"},{"fix":"Use a dedicated SQL formatter like sql-formatter for complex queries.","message":"SQL formatting is very basic; complex queries may not be formatted correctly.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'0.40.0':19 '2016':29 'activ':26 'beautifi':54,85 'common':42 'commonj':81 'css':14,89 'data':3,43,59 'depend':33 'develop':27 'e.g':51 'esm':76 'format':39,44,50,62 'formatt':46 'function':37 'handl':60 'javascript':82 'js':53 'js-beautifi':52 'js/html/css':56 'json':13,88 'lack':68 'latest':22 'librari':5 'lightweight':30 'minifi':11,41,86 'modular':75 'multipl':61 'one':49 'packag':66 'pretti':2,8,58,83 'pretty-data':1,57 'pretty-print':7 'print':9,84 'provid':35 'releas':24 'shake':71 'simpl':36 'sinc':28 'singl':65 'specif':47 'sql':16,90 'stabl':23 'string':17 'support':79 'tree':70 'tree-shak':69 'unlik':45 'version':18 'xml':12,87 'zero':32","created_at":"2026-06-05T17:01:02.665162+00:00","updated_at":"2026-06-05T17:01:02.665162+00:00","problems":[{"fix":"Ensure const pd = require('pretty-data'); then use pd.json.prettyPrint.","cause":"Attempting to use pd.json.prettyPrint directly if pd is the result of a property access without the default import.","error":"TypeError: pd.json.prettyPrint is not a function"},{"fix":"Convert object to string: pd.json.prettyPrint(JSON.stringify(obj)).","cause":"Passing a JavaScript object to pd.json.prettyPrint instead of a JSON string.","error":"SyntaxError: Unexpected token o in JSON at position 1"},{"fix":"Check that the input is a valid string before calling prettyPrint or min.","cause":"Passing undefined or null to pd.json functions.","error":"Unexpected token u in JSON at position 0"},{"fix":"Run npm install pretty-data, then use require('pretty-data').","cause":"The package is not installed or import path is incorrect.","error":"Cannot find module 'pretty-data'"},{"fix":"Add const pd = require('pretty-data'); at the top of the file.","cause":"Forgetting to require the library before using pd.","error":"ReferenceError: pd is not defined"}],"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":"http://github.com/vkiryukhin/pretty-data","github":"http://github.com/vkiryukhin/pretty-data","docs":null,"changelog":null,"pypi":null,"npm":"pretty-data","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"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}}