19

There are number of extensions in Visual Studio Code (VS Code) to prettify JSON files. But is there an extension or setting, which enables me to view all *.json files pre-formatted / pre prettified? I find it tedious to constantly press shift-alt-F + ctrl-s when viewing ugly one line json-data, especially if the content of the file is being updated regularly back to pre-formatted form.

Vettis
  • 313
  • 1
  • 2
  • 9

3 Answers3

37
On Windows:    Shift + Alt + F  
On Mac:        Shift + Option + F  
On Linux:      Ctrl + Shift + I  

Original answer How do you format code in Visual Studio Code (VSCode)?

I'm adding it here because when I was looking for it I found your post before the other one. Hope it helps.

manuelbcd
  • 3,106
  • 1
  • 26
  • 39
  • 1
    The ideal solution to the original question would not involve pressing any key combos. Nonetheless thanks for leaving this documenting answer! – Kamaradski Jun 16 '23 at 13:11
2

You can download JsonPrettifier extension.

0

Be aware that if you have the setting

JSON > format: Keep Lines

enabled (the default is disabled), that a one-liner JSON file (or any JSON that has multiple key/values on the same line) will not be formatted as you wish. The file might not change at all until you disable the Keep Lines setting and re-format.

Mark
  • 143,421
  • 24
  • 428
  • 436