Skip to content
Advertisement

Add a line break automatically after comma in JSON file?

I have a JSON file automatically generated from my PHP laravel backend, it’s just an array converted to JSON format, problem is I’d like to have a the JSON file row by row instead of this ugly mess of serialized data…

This is how my JSON file looks:

JavaScript

If you past it into your IDE (mine is Visual Studio Code) you will see how ugly it looks, because of it syntax hilighting doesn’t even work…

Advertisement

Answer

json_encode() has a JSON_PRETTY_PRINT option. Something like this should work:

JavaScript

This results in an output like this:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement