Eric Bergman-Terrell's Blog

Node.js Programming Tip: How to Pretty-Print XML
September 14, 2015

This website's XML Pretty-Print utility uses the following code to convert JSON text into ready-to-read XML. Obviously, pretty-data is doing all the work. The second argument to the xml function specifies whether or not to retain XML comments.

var pd = require('pretty-data');

exports.prettyPrint = function(source) {
    return pd.pd.xml(source, true);
};
Pretty Print XML

I am pretty and well-formed!

Keywords: Node.js, node, Express, JavaScript, XML, pretty print, formatting, pretty-data, comments

Reader Comments

Comment on this Blog Post

Recent Posts

TitleDate
.NET Public-Key (Asymmetric) Cryptography DemoJuly 20, 2025
Raspberry Pi 3B+ Photo FrameJune 17, 2025
EBTCalc (Android) Version 1.53 is now availableMay 19, 2024
Vault 3 Security EnhancementsOctober 24, 2023
Vault 3 is now available for Apple OSX M2 Mac Computers!September 18, 2023
Vault (for Desktop) Version 0.77 ReleasedMarch 26, 2023
EBTCalc (Android) Version 1.44 is now availableOctober 12, 2021