PowerShell to XML Converter
Paste PowerShell objects or hashtables. Get clean XML back.
Input
Output
Paste your PowerShell code on the left and press Convert.
Or drop a file on this box, , or .
What this tool does
Sooner or later a PowerShell script has to hand data to something that only reads XML: a DSC resource, an MSBuild property file, a web.config transform, a SoapUI test step. The built-in options both disappoint. ConvertTo-Xml buries your values inside generic <Object Type="..."> and <Property Name="..."> nodes, and Export-CliXml writes CLIXML that only PowerShell wants to read back. Paste the object here and our converter answers with plain XML where OrderId is simply an <OrderId> element.
The converter reads the literal syntax you already write. A PSCustomObject keeps its property order, since PowerShell itself preserves insertion order there, and each property becomes an element. An ordinary @{ City = "London" } hashtable nests the same way. An @(...) array is turned into a wrapper with an element per entry, and a [PSCustomObject] inside another one shows up as a nested element rather than the @{Sku=SKU-101; Qty=2} string you get from careless string conversion. $true and $false are written as true and false, and $null leaves an empty element so the field is still visible.
Some quirks of the language are handled the way a human would expect. Double-quoted strings come through without interpolation markers like $var expanded: we preserve what you pasted literally. Here-strings (@" ... "@) are treated as multi-line text content. Dates written as [datetime]"2026-04-21" are emitted as ISO-8601 strings. Property names that contain dashes get a safe element name (PowerShell lets you write "User-Agent" = "..." in a hashtable, which is illegal as a raw XML tag: we convert it so the output still parses). The shape stays faithful to the input; the XML stays usable.
How to use it
Paste, press Convert, copy. The details below are specific to PowerShell input.
Paste your PowerShell (or try the sample)
Paste the script into the left editor. Load Sample shows the expected input: a $order = [PSCustomObject]@{...} with an Items array of two line items, a nested ShippingAddress and an InternalNote = $null so you can see what happens to a null.
You do not need to strip comments, remove param() blocks, or clean the script up beforehand. Paste what you have. We will read only the object literals and ignore the rest.
Hit Convert
Press the green Convert button. The script text goes to our backend, which reads the object literals (it does not run anything, so Get-ADUser calls stay unexecuted) and returns XML. While that happens the editors are covered by a "Converting..." overlay.
Copy the XML
Your XML shows up in the right-hand editor. If you want to load it straight back into a script, cast it with [xml] and walk it like any other XmlDocument; otherwise paste it into your DSC configuration data or MSBuild file.
When this actually comes in handy
Authoring DSC configuration payloads
You have a PowerShell hashtable that describes a node configuration and you need an XML version of it for a non-DSC consumer or for documentation. Paste, convert, done, no more babysitting ConvertTo-Xml output.
Azure DevOps pipeline variable files
Pipelines sometimes expect a variable group as XML. Paste the PowerShell hashtable you already maintain, get back XML that drops straight into variables.xml, no hand-editing.
Exporting Windows event-log payloads
When you build an event record in PowerShell as a PSCustomObject and need to feed it to a logging pipeline that ingests XML, this saves you from writing a custom serializer. The nested shape comes through unchanged.
app.config / web.config seed templates
Turn a PowerShell settings hashtable into a starting-point app.config you can edit by hand. Faster than generating one from scratch and keeps the keys in sync with your scripts.
Common questions
How is this different from running ConvertTo-Xml on my object?
ConvertTo-Xml wraps everything in a generic <Object Type="..."><Property Name="..."> envelope: readable by PowerShell, ugly everywhere else. This tool emits the property names as actual XML elements, so the output looks the way a person would write XML by hand. No <Property Name> indirection, no type attribute clutter.
Does it produce CLIXML like Export-CliXml does?
No, and that is the point. Export-CliXml outputs CLIXML, which is a PowerShell-specific format designed for round-tripping back into PowerShell. If you need to hand the XML to a system that is not PowerShell (a Java service, a config reader, an XSD-validated pipeline), CLIXML is the wrong shape. This tool gives you plain, readable XML instead.
Can I paste a full .ps1 file or just object literals?
Paste whatever you have. If the script contains a single object literal assigned to a variable, that is what comes through. If there are multiple top-level hashtables or PSCustomObjects, each one is emitted as its own element. Function bodies, param() blocks, imports, and Write-Host lines are ignored, only the data shapes matter.
How are $null, $true, $false, and empty arrays handled?
$null becomes an empty self-closing element so the shape stays consistent (instead of the field disappearing). $true and $false become the literal strings true and false. An empty @() becomes an empty container element. That way downstream tooling always sees the same structure even when some fields are unset.
What about hashtable keys that are not valid XML names: dashes, spaces, numbers first?
Keys like "User-Agent" or "2024-Q1" are legal in a PowerShell hashtable but illegal as raw XML element names. We rewrite them to a safe form (keeping the original as an attribute where that makes sense) so the output still parses. If that matters for your consumer, look over the generated tags first.
Is my code stored?
Clicking Convert sends the script text to our backend for that one conversion; the reply holds the XML and the site saves nothing. Admin scripts love to carry ConvertTo-SecureString plaintext, tenant IDs and service account names, so strip those out before you paste.
Other tools you may need
Need JSON from the same PSCustomObject, or want to read and check the XML you just produced? Try these: