Convert HCL to JSONC

Turn HCL files into JSONC. Blocks nest by type and label as in the JSON form of HCL, and repeated blocks without labels become a list.

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 files as plain JSON.Blocks nest by type and label, and the result is one JSONC file.

  1. What you get

    A single JSONC file built from your HCL. Blocks nest by type and label, as in the JSON form of HCL. Repeated blocks that have no labels become a list.

    The output is written as plain JSON, which every JSONC reader accepts. No comments are added.

  2. What changes

    Expressions such as references, function calls and type names become text in the form ${...}. An escaped ${ loses its escape.

    Comments in the HCL file are dropped, so notes you wrote beside settings are not in the JSONC file.

  3. When it fails

    A file that cannot be parsed stops with input_corrupted. This is the code for an HCL file the converter cannot read.

    To go the other way, use JSONC to HCL.

HCL and JSONC.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 · JSONC

JSON with Comments

JSON that allows comments, as in editor and TypeScript configuration files.

Extensions
.jsonc
MIME type
text/x-jsonc
Kind
Text and data

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

terminal
$ cv convert report.hcl report.jsonc
$ cv convert report.hcl report.jsonc

Questions.What people ask about HCL to JSONC.

01OF 04

No. Comments are dropped, and the converter does not add any to the JSONC file.

They become ${...} text. The same goes for type names.

The input can be HCL, Terraform or tfvars files, with the extensions hcl, tf and tfvars. Each conversion gives one file.

The file could not be parsed. The conversion stops with this code.

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