DEV Community

Pacharapol Withayasakpunt
Pacharapol Withayasakpunt

Posted on


Forgiving pretty-print

What is the best way to pretty print a possibly malformed JSON string? (which is a very long string, impossible to validate and fix by eyes...)

Pretty printing should work, albeit partially, if JSON is malformed.

Just like web browser can render malformed HTML.

Top comments (5)

patarapolw profile image
Pacharapol Withayasakpunt • Edited

My challenge is JSON is malformed, but pretty-printing should still works. (probably to a limited extent)

dawx profile image

I guess you could use JSON Formatter extension for chrome it will format it on screen but I don't know if how it would look like if you print it, worth a try though

This post blew up on DEV in 2020:

js visualized

🚀⚙️ JavaScript Visualized: the JavaScript Engine

As JavaScript devs, we usually don't have to deal with compilers ourselves. However, it's definitely good to know the basics of the JavaScript engine and see how it handles our human-friendly JS code, and turns it into something machines understand! 🥳

Happy coding!