79644730

Date: 2025-05-29 23:29:52
Score: 0.5
Natty:
Report link

For anyone wanting to do this in Javascript, here's a wrapper for JSON.stringify that can do it for any kind of spacing:

const toPrettyJSONString = (value, replacer = null, space = "\t") =>
    JSON.stringify(value, replacer, space).replace(new RegExp("(\n\\s*)(.*?:) ([\\[{])(?=\n)", "g"), "$1$2$1$3");
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Benjamin Penney