{"id":20875,"library":"xml-but-prettier","title":"xml-but-prettier","description":"A minimal XML beautifier that formats XML documents by placing each tag and text node on its own line with proper indentation. The current stable version is 1.0.1, released in 2017 with no further updates since. It is a fork of xml-beautifier and offers a simple function signature with two options: indentor (custom indentation string) and textNodesOnSameLine (to compress text nodes onto the same line as their parent tags). It supports ESM imports and has no runtime dependencies.","status":"maintenance","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/shockey/xml-but-prettier","tags":["javascript"],"install":[{"cmd":"npm install xml-but-prettier","lang":"bash","label":"npm"},{"cmd":"yarn add xml-but-prettier","lang":"bash","label":"yarn"},{"cmd":"pnpm add xml-but-prettier","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package exports a single default function. CommonJS require works but ESM is preferred.","wrong":"const xmlButPrettier = require('xml-but-prettier')","symbol":"default","correct":"import xmlButPrettier from 'xml-but-prettier'"},{"note":"It's a default export, not a named export.","wrong":"import { xmlButPrettier } from 'xml-but-prettier'","symbol":"xmlButPrettier","correct":"import xmlButPrettier from 'xml-but-prettier'"},{"note":"TypeScript users should use default import syntax; no bundled type definitions exist.","wrong":"import xmlButPrettier = require('xml-but-prettier')","symbol":"default type","correct":"import xmlButPrettier from 'xml-but-prettier'"}],"quickstart":{"code":"import xmlButPrettier from 'xml-but-prettier';\n\nconst ugly = '<div><span>foo</span><p>bar</p></div>';\nconst pretty = xmlButPrettier(ugly, {\n  indentor: '  ',\n  textNodesOnSameLine: true\n});\nconsole.log(pretty);\n// Output:\n// <div>\n//   <span>foo</span>\n//   <p>bar</p>\n// </div>\n","lang":"javascript","description":"Formats an XML string with 2-space indentation and keeps text nodes on the same line as their parent tags."},"warnings":[{"fix":"Update call to use config object: xmlButPrettier(xml, { indentor: '  ', textNodesOnSameLine: true }).","message":"Options moved from second argument to config object in v1.0.0. Previously, options were passed as separate arguments, e.g. xmlButPrettier(xml, '  ', true). Now they must be passed as an object: xmlButPrettier(xml, { indentor: '  ', textNodesOnSameLine: true }).","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Upgrade Node.js to version 4 or higher.","message":"Node.js 0.12 support dropped in v1.0.0.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Consider using an actively maintained alternative like 'xml-formatter' or 'pretty-data'.","message":"No releases since 2017. The package is in maintenance mode and may not receive updates.","severity":"deprecated","affected_versions":">=1.0.1"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use import xmlButPrettier from 'xml-but-prettier'","cause":"Using named import instead of default import.","error":"TypeError: xmlButPrettier is not a function"},{"fix":"Call xmlButPrettier(xml, { indentor: '  ', textNodesOnSameLine: true })","cause":"Passing options as separate arguments instead of config object in v1.x. Options must be an object.","error":"Error: Expected a string, got object"},{"fix":"Run npm install xml-but-prettier","cause":"Package not installed or not in node_modules.","error":"Cannot find module 'xml-but-prettier'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}