Json formatting for debug using powershell, jq and Visual Studio Code

When I’m debugging applications, I usually need to check some JSON responses.

If you only want to see the formatted JSON, you can use jq with PowerShell (BTW I installed jq using chocolatey), running the following PowerShell command in your terminal:


But usually, I have a considerable chunk of JSON data, and I want to be able to interact with the tree and collapse it.

To do that, I can create a PowerShell script with the following snippet and save it in a folder included in my path and then call it from a PowerShell prompt after copying the JSON to the clipboard.

$clipboardFile = "$env:TEMP\clipboard.json"
get-clipboard > $clipboardFile|code $clipboardFile

For example, I created the file jtoc.ps1 in my c:\windows folder, and I can copy the following JSON to the clipboard {"Hello":"json formatter","Using":"vs code"} and then use jtoc in the terminal and it will open in vs code, then I use ALT+SHIFT+F to format the text.

I hope this was useful and a better way to check your JSON data.

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s