HCL ↔ JSON

Client

Convert between HashiCorp Configuration Language (HCL) and JSON in your tab—paste on either side, format, and copy. A small Terraform-style example is pre-filled so you can try HCL → JSON immediately; pair with HOCON ↔ JSON when the file is JVM config instead of .tf blocks.

Learn more: JSON and HCL

Exchange HashiCorp Configuration Language (HCL) with JSON—typical for Terraform and OpenTofu .tf snippets—without uploading files or running plan/apply.

What HCL is here

HCL expresses infrastructure and provider settings as nested blocks (`resource`, `variable`, `module`, and similar) with attribute assignments. This page parses pasted HCL into JSON trees using an hcl2json-compatible shape and emits draft HCL from matching JSON or a locals { } wrapper for generic objects.

Limits

Complex expressions, heredocs, and dynamic blocks may not round-trip perfectly. Output is for inspection and drafting—run terraform validate or equivalent in your environment before relying on generated files.

This page does not download modules, query registries, or apply changes—paste complete snippets only.

Nearby workflows on Toolcore

  • HOCON ↔ JSONHOCON config to JSON and JSON to HOCON online—format, validate, convert locally. once JSON text parses on this page.
  • TOML ↔ JSONTOML to JSON and JSON to TOML online—format, validate, convert locally. once JSON text parses on this page.
  • YAML ↔ JSONYAML to JSON and JSON to YAML online—bidirectional converter, format either side in the browser. once JSON text parses on this page.
  • JSON formatterJSON format online: pretty-print, minify, validate, escape, download . once JSON text parses on this page.

Common use cases

  • Inspect Terraform or OpenTofu snippets as JSON trees before refactoring modules or variables.
  • Draft HCL blocks from hcl2json-shaped JSON exported by other tooling or documentation generators.
  • Normalize pasted .tf fragments after manual edits so block structure is easier to review.

Common mistakes to avoid

  • Expecting byte-for-byte round trips

    JSON → HCL reorders attributes and may wrap unfamiliar roots in locals { }. Always diff against your module conventions before committing.

  • Treating output as validated Terraform

    This page parses and emits text only—it does not run terraform validate, plan, or apply.

  • Confusing HCL with HOCON or YAML

    HCL uses block headers like resource "type" "name" { }. For JVM application.conf use HOCON ↔ JSON; for strict tables use TOML ↔ JSON.

FAQ

Are files uploaded?

No. Parsing and conversion run in your browser tab.

Does this fetch remote modules or providers?

No. Paste complete HCL text—there is no network step.

Which JSON shape works best for JSON → HCL?

Trees produced by hcl2json (block type → labels → array of attribute objects) emit familiar resource and variable blocks. Other objects become a locals { } wrapper.

Common search terms

Phrases people search for that match this tool. See the full long-tail keyword index.

  • hcl to json converter online
  • terraform hcl to json browser
  • json to hcl draft generator
  • opentofu hcl parse locally
  • convert tf snippet to json no upload

Related utilities you can open in another tab—mostly client-side.