Pretty-Print JSON With PowerShell
Reformat minified JSON into indented, readable output.
Run the pipeline to parse a JSON string and print it formatted.
01Command
Command
$ '{"name":"cmdcv","tags":[1,2,3]}' | ConvertFrom-Json | ConvertTo-Json02What 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
!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-JsonEvidence: Converts objects to JSON; -Depth controls how deep nested structures are serialized.
Last verified: 2026-09-20 · Category: Developer
06Related solutions
Grep on Windows: Select-String
Search inside text files and logs with regex, returning file, line number and match.
Zip Files with Compress-Archive
Create or update a .zip from any files or folder contents straight from PowerShell.
Test a TCP port connection on Windows with Test-NetConnection
A built-in PowerShell one-liner that answers 'is port 5432/3389/443 actually open through this network?' — no telnet client needed.