PowerShell to JSON Converter
Paste a PowerShell hashtable or PSCustomObject. Get JSON back.
What this tool does
If you have ever copied a @{...} hashtable out of a PowerShell script and needed the JSON equivalent — without opening a shell and piping through ConvertTo-Json — that is what this tool is for. Paste the PowerShell, get clean JSON back. Works for a single hashtable, a [PSCustomObject] instance, or a whole chain of nested @{} blocks with arrays inside.
The output matches what ConvertTo-Json -Depth 100 would give you. Hashtables and [PSCustomObject] both become JSON objects. Arrays (@(1,2,3)) become JSON arrays. $null becomes null, $true/$false become JSON booleans. DateTime values are emitted as ISO-8601 strings, the same convention PowerShell 7 uses.
Keys that contain spaces or special characters stay quoted. Numeric literals (42, 3.14) stay numbers. Single-quoted and double-quoted strings both parse correctly and double-quoted escape sequences (`n, `t) are resolved. If you paste multiple top-level assignments, each becomes a key in the output JSON, named after the variable.
How to use it
Three steps. Works the same whether you paste a two-key hashtable or a full configuration block.
Paste your PowerShell (or try the sample)
Drop your script snippet into the left editor. A hashtable, a [PSCustomObject], nested @{} blocks, or an array of objects — all fine. Load Sample shows a realistic order example.
You do not need to clean anything up — leave the $variable prefixes, the [PSCustomObject] casts, and the comments exactly as they are.
Hit Convert
Click the green Convert button. The tool parses the hashtable, walks every nested structure, and builds the JSON in one pass.
Copy the JSON
The right panel fills with indented JSON. Paste into an ARM template, an Invoke-RestMethod body, or a JSON fixture for a Pester test.
When this actually comes in handy
Building REST API request bodies
You have a hashtable ready to send via <code>Invoke-RestMethod</code> and want to verify the JSON shape first. Paste, inspect, then ship.
Converting config hashtables to JSON files
A team uses <code>.psd1</code> config files, but a new service expects JSON. Paste the hashtable and save the output as <code>config.json</code>.
ARM / Bicep parameter files
ARM template parameters are JSON, but you often build them up as PowerShell hashtables first. Convert once and commit the JSON.
Feeding downstream tools
CI scripts in PowerShell often need to hand structured data to Python, Node, or a container command that expects JSON on stdin. This is that handoff.
Common questions
Does it match ConvertTo-Json output?
Yes — the goal is parity with ConvertTo-Json -Depth 100 -Compress:$false. Hashtables and [PSCustomObject] objects both become JSON objects; arrays become JSON arrays; $null, $true, $false map the usual way.
What about [PSCustomObject] vs a plain hashtable?
Both convert to the same JSON object. [PSCustomObject] preserves property order, which this tool respects. Plain hashtables are alphabetized by default — same as ConvertTo-Json.
Can I paste a whole script?
Yes, but only the top-level $variable = @{...} and [PSCustomObject]@{...} assignments are included in the output. Function definitions, control flow, and cmdlet calls are ignored. Each top-level variable becomes a key in the JSON, named after the variable.
How are dates and numbers handled?
[DateTime] and Get-Date outputs are emitted as ISO-8601 strings. Numeric literals (including decimal [decimal]) stay as JSON numbers. Dates pasted as raw strings are kept as strings.
Is my code stored?
Your code is sent to the backend for conversion and is not persisted — we do not log the payload. If the hashtable contains secrets, redact them before pasting.
Does it handle here-strings and multi-line string values?
Yes. @"..."@ and @'...'@ here-strings are preserved as JSON strings with proper newline encoding.
Other tools you may need
PowerShell to JSON pairs well with the rest of the toolbox: