Pretty-Print JSON With PowerShell

Reformat minified JSON into indented, readable output.

WindowsscriptingjsonpowershellLow risk
Run the pipeline to parse a JSON string and print it formatted.

01Command

Command
$ '{"name":"cmdcv","tags":[1,2,3]}' | ConvertFrom-Json | ConvertTo-Json

02What it does

ConvertFrom-Json turns text into PowerShell objects and ConvertTo-Json serializes them back with indentation. Add -Depth to avoid truncating nested objects, and use it on Invoke-RestMethod results to inspect API responses clearly.

03Risk

RiskLow risk
RequirementsWindows 10/11 with PowerShell 5.1 or PowerShell 7+
!Warning: The default -Depth is 2, so deeply nested JSON can be truncated with a warning; set a higher depth explicitly.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • ConvertTo-Json
    Microsoft Learn · vendor-doc · 2026-09-20
    Evidence: Converts objects to JSON; -Depth controls how deep nested structures are serialized.

Last verified: 2026-09-20 · Category: Developer

06Related solutions