Registry / serialization / xml-but-prettier

xml-but-prettier

JSON →
library1.0.1jsnpmunverified

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.

npm install xml-but-prettier
INSTALL
IMPORT
SIG · XML-BUT-PRETTIER
X
xml-but-prettier
serializationjavascriptv1.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import xmlButPrettier from 'xml-but-prettier'
const xmlButPrettier = require('xml-but-prettier')
Package exports a single default function. CommonJS require works but ESM is preferred.
xmlButPrettier
import xmlButPrettier from 'xml-but-prettier'
import { xmlButPrettier } from 'xml-but-prettier'
It's a default export, not a named export.
default type
import xmlButPrettier from 'xml-but-prettier'
import xmlButPrettier = require('xml-but-prettier')
TypeScript users should use default import syntax; no bundled type definitions exist.

Formats an XML string with 2-space indentation and keeps text nodes on the same line as their parent tags.

import xmlButPrettier from 'xml-but-prettier'; const ugly = '<div><span>foo</span><p>bar</p></div>'; const pretty = xmlButPrettier(ugly, { indentor: ' ', textNodesOnSameLine: true }); console.log(pretty); // Output: // <div> // <span>foo</span> // <p>bar</p> // </div>
xml-but-prettier --version
Debug
Known issues
breakingOptions 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 }).
fix
Update call to use config object: xmlButPrettier(xml, { indentor: '  ', textNodesOnSameLine: true }).
affects: <1.0.0
breakingNode.js 0.12 support dropped in v1.0.0.
fix
Upgrade Node.js to version 4 or higher.
affects: <1.0.0
deprecatedNo releases since 2017. The package is in maintenance mode and may not receive updates.
fix
Consider using an actively maintained alternative like 'xml-formatter' or 'pretty-data'.
affects: >=1.0.1
Errors
Common errors & fixes
TypeError: xmlButPrettier is not a function
Using named import instead of default import.
fix
Use import xmlButPrettier from 'xml-but-prettier'
Error: Expected a string, got object
Passing options as separate arguments instead of config object in v1.x. Options must be an object.
fix
Call xmlButPrettier(xml, { indentor: '  ', textNodesOnSameLine: true })
Cannot find module 'xml-but-prettier'
Package not installed or not in node_modules.
fix
Run npm install xml-but-prettier
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
25 hits · last 30 days
node
22
OpenAI (training)
1
Resources
xml-but-prettier — npm install xml-but-prettier · libregistry