Is there a way to view JSON files automatically prettyfied in Visual Studio Code?
Asked Answered
P

4

55

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.

Proponent answered 24/3, 2021 at 12:29 Comment(0)
W
115
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.

Willey answered 1/8, 2022 at 8:7 Comment(3)
The ideal solution to the original question would not involve pressing any key combos. Nonetheless thanks for leaving this documenting answer!Musette
I get there is not formateer for binary text file installed messageMoidore
I've made this and was requested to add a formatter. A side window opened, where I've placed category:formatters plaintext prettier. So, I installed Prettier. Next time I've pressed the combo keys I was required to setup the default formatter. And that's it.Alkane
R
2

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.

Roland answered 27/7, 2023 at 1:45 Comment(1)
"json.format.keepLines": falseMiddle
L
1

You can download JsonPrettifier extension.

Lawyer answered 24/3, 2021 at 12:32 Comment(1)
Unless this automatically format the file upon opening, it does not answer the original questionMusette
T
-1

you can dowlnoad JSON from Meezilla extension and then Press Cmd/Ctrl+Shift+J to quick beautify with default config.

Torbernite answered 17/5 at 15:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.