Paste Perl on the left and click "Convert" — we will turn it into XMLPaste Perl code

What this tool does

If you maintain Perl that feeds XML into anything — an older SOAP service, an XML-based config, a CPAN-driven integration — you know the ritual: use XML::Simple, fiddle with ForceArray and KeyAttr, hand-roll a hash ref, and hope the output is what the consumer expects. Paste the Perl here and get back well-formed XML in one pass — a blessed object, a plain hash ref, or a whole package with a constructor and accessors.

The converter reads the common Perl OO patterns cleanly. A constructor that does bless $self, $class with a hash ref becomes an XML element whose children mirror the hash keys. Array refs turn into container elements with one child per entry (named after a singular form of the key, so items => [...] becomes <items><item/>...</items>). Nested hash refs become nested elements. undef becomes an empty element rather than being dropped, so the shape matches what XML::Simple or XML::LibXML would round-trip.

You can paste multiple package blocks at once — package Order; package OrderItem; package Address; — and each one comes through with its constructor-assigned fields expanded. Plain non-OO data structures work too: feed in my $data = { ... }; and the tool walks the refs, preserving hash keys as element names. For the deeper Perl rules behind all this, the official perldoc is the reference.

How to use it

Three steps. Works the same whether you paste a ten-line package or a full module with helpers.

1

Paste your Perl (or load the sample)

Drop the code into the left editor as-is. A package with a constructor, a plain hash ref, nested packages, or a mix — all fine. Hit Load Sample to see a realistic example first.

No need to strip use strict;, use warnings;, or your require list. Leave the code the way it looks in your editor. Just paste.

2

Hit Convert

Click the green Convert button. The tool reads the package declarations, resolves the blessed references, and builds the XML in one pass. A short loading indicator runs while it works.

3

Copy the XML

The right panel fills with indented, well-formed XML that any standards-compliant parser will accept. Copy it straight into your CPAN workflow, a legacy SOAP integration, an XML-based config file, or a test fixture.

When this actually comes in handy

Feeding XML::LibXML or XML::Simple

You have a Perl data structure and want to see exactly what it looks like as XML before wiring up <code>XMLout</code> / <code>XML::LibXML::Document</code>. Paste, convert, copy, compare.

Legacy system integration

A CPAN-backed integration still expects SOAP 1.1 or a bespoke XML format. Paste your Perl representation and get a realistic body to hand to SoapUI or curl.

Migrating away from Perl

Replacing an old Perl service with something else? Export the data shape as XML first — it is the neutral ground for porting to Python, Java, or C#.

Docs that match the code

Generate XML examples for a <a href="https://metacpan.org/" target="_blank" rel="noopener">MetaCPAN</a> module README or an internal wiki straight from your actual packages, so the docs do not drift.

Common questions

Can I paste multiple packages at once?

Yes — paste a whole .pm file or several package blocks stacked together. Each package comes through with its constructor-assigned hash keys expanded and nested object refs resolved. If Order holds an array ref of OrderItem objects and a shipping_address hash ref, all three land in the output.

How does it handle undef and missing keys?

A key whose value is undef becomes an empty element so the XML shape stays stable across instances. Keys that are missing entirely from the hash are omitted. Array refs with empty arrays become empty container elements (<items></items>) rather than being dropped.

Do array refs and hash refs work the same way?

An array ref becomes a container element with one child per entry — by default the child tag is a singular form of the key (so items => [...] yields <items><item/>...</items>). A hash ref becomes a nested element whose children mirror the keys. Mixed refs (array of hash refs, hash of arrays) nest the same way recursively.

What about blessed references and multiple inheritance?

Blessed references keep their class name available — it can be used as the element tag when it makes sense. For multi-inheritance via @ISA or Moose/Moo roles, the attributes on the final composed object come through; we do not try to reconstruct the inheritance graph in XML.

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 Perl is sensitive (credentials in literals, internal URLs), give it a quick pass before pasting, same as any online tool.

What if the Perl uses subroutine refs or tie?

Code refs and tied variables are emitted as empty elements rather than failing the whole conversion. The data portion of your structure still comes through. If the code itself has syntax errors, fix the obvious ones first so the parser has something clean to work with.

Other tools you may need

Perl to XML is one piece of the puzzle. These tools pair well with it: