Format JSON before writing to a file

Dear Father, I am sinning - I'm writing a flow to modify flows.json :frowning:

Now that's over with :slight_smile: is there an easy method of nicely formatting my JSON before writing it to file

e.g instead of this

I get this
image

Via function node...

JSON.stringify(object, null, 4); //4 is the number of spaces for formatting

If your object is JSON, then run JSON.parse first

JSON.stringify(JSON.parse(flowString), null, 2);
1 Like

Guess what I just spotted :slight_smile:
image

2 Likes

Ha - never noticed that!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.