I’m using the Postman extension in Visual Studio Code to test my API endpoints. When I send a request and receive a JSON response, the data is displayed in an unformatted, "ugly" structure, making it hard to read (see screenshot below).
I’ve tried switching to the "Pretty" view, but it doesn’t seem to improve the formatting.
Are there any settings in the Postman extension for VS Code to improve JSON formatting? Or are there alternative ways to display the response in a readable, structured format directly within Visual Studio Code?
Any help would be appreciated!
2
Answers
Prettier is widely used for JSON formatting in VS Code. install it from VS extension.
Then configure Prettier for JSON :
In VS code settings -> File > Preference > Settings
search for Prettier and ensure enabled for JSON files.
To automatically format JSON on save, add this to your settings.json
{ "editor.formatOnSave": true, "[json]": { "editor.defaultFormatter": "esbenp.prettier-vscode" } }
This is currently bugged, as described in https://github.com/postmanlabs/postman-app-support/issues/13230
Check the linked issue for possible workarounds