Convert HCL to XML

Turn HCL files into XML. Objects become elements inside one root element and every value becomes text, with characters a tag name cannot hold turned into underscores.

Converted in an isolated sandbox on our serversDeleted after 24 hours

Drop HCL files on the dialor turn it to pick what to do

Terraform config as an XML document.Blocks become nested elements inside one root element.

  1. What you get

    One XML file. The whole HCL file sits inside a single root element, and objects become elements within it.

    Blocks nest by type and label, so a resource block ends up as elements named for its type and its label. Expressions are written as ${...} text.

  2. How values are written

    Every value becomes text. Characters that a tag name cannot hold are turned into underscores, so a key with such a character gets a changed element name.

    Keys starting with @ become attributes. Lists and objects set as attributes are written as JSON text. A key named #text becomes the element's own text.

  3. What changes with lists

    A list repeats its element, once per item. An empty list therefore disappears from the output, and a list of lists is flattened into one run of repeated elements.

    To go the other way, use XML to HCL.

HCL and XML.What each format is.

The formats

From · HCL

HCL

HashiCorp Configuration Language, what Terraform and Packer files are written in.

Extensions
.hcl .tf .tfvars
MIME type
application/x-hcl
Kind
Text and data
To · XML

XML

XML documents and data.

Extensions
.xml
MIME type
application/xml
Kind
Text and data

In your code.The same HCL to XML conversion through the API, for your app or your agent.

terminal
$ cv convert report.hcl report.xml
$ cv convert report.hcl report.xml

Questions.What people ask about HCL to XML.

01OF 04

Yes. HCL files with the extensions hcl, tf and tfvars are all read as HCL.

No. Every value becomes text in the XML.

It disappears. A list repeats its element once per item, so an empty list leaves no element.

As ${...} text inside the element.

More conversions.Other ways in and out of HCL and XML.