Skip to main content

JSON to HCL Converter

Convert a Terraform JSON configuration (.tf.json) back to native HCL syntax — recognizes Terraform's well-known block types (resource, data, variable, output, module, provider, lifecycle, provisioner, dynamic, …) and unwraps `${...}` interpolation strings back into raw expressions. Runs entirely in your browser.

Input

Drop a file or browse
One file · text
Or

Output

HCL output
 
Was this helpful?

Guides

Paste a Terraform JSON configuration (.tf.json), get native HCL (HashiCorp Configuration Language) syntax back — the same .tf format you'd hand-write. Recognizes Terraform's well-known block types (resource, data, variable, output, module, provider, terraform, locals, and common nested blocks like lifecycle/provisioner/dynamic) and renders them as proper labeled blocks instead of JSON objects. Conversion happens as you type, with no upload and no sign-up.

How to use it

  1. Paste your Terraform JSON into the input box, or upload a .tf.json file — its contents drop straight into the editor.
  2. The HCL output appears instantly on the right, syntax-highlighted.
  3. Copy it, or download it as a main.tf file.

A recognized block keyword (see above) nests through its labels — {"resource":{"aws_instance":{"web":{...}}}} becomes resource "aws_instance" "web" { ... } — and a JSON array of bodies under an unlabeled block type becomes repeated blocks. A string value that's entirely a ${...} wrapper (exactly what the sibling HCL to JSON Converter produces for a reference or function call) unwraps back into a raw, unquoted expression — so "instance_type": "${var.instance_type}" becomes instance_type = var.instance_type, not a quoted string.

What happens to a JSON object that isn't a recognized block type?

It renders as a literal HCL map/object attribute, e.g. {"tags":{"Name":"web"}} becomes tags = { Name = "web" }. This is a deliberate, documented choice: without your provider's schema, a nested object is genuinely ambiguous between "block" and "map attribute" (see the HCL to JSON Converter's FAQ on the same issue) — recognizing only Terraform's own well-known keywords keeps the output predictable, at the cost of not guessing at provider-specific block names it doesn't know.

Does the root of my JSON need to be an object?

Yes — Terraform's JSON syntax requires the document root to be a JSON object, same as a real .tf.json file. A root array or a bare scalar value is rejected with an error.

Is my data private?

Completely. Parsing and conversion both run locally in your browser — your JSON, including any secrets or hostnames in it, is never sent to a server.

Need the other direction, or just to format HCL?

Use the HCL to JSON Converter to go from native Terraform syntax to JSON, or the Terraform Formatter to clean up an existing .tf file's indentation and argument order.

terraformhcljsontf.jsoninfrastructure as codeiacdevopsconfigjson2hcl

Use it from code

From 3 credits per call

REST API

curl -X POST https://api.iotools.cloud/v1/tool/json-to-hcl-converter \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonSource": "{\n  \"resource\": {\n    \"aws_instance\": {\n      \"w…"
  }'

Swap in your own key from your account. The tool's fields are the body — no wrapper.

Ask an AI agent

Use the IOTools `json-to-hcl-converter` tool (JSON to HCL Converter) on this input:

YOUR_INPUT_HERE

Paste this at any agent connected to the IOTools MCP server, then add your input.

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.