Blog
Wild & Free Tools

Convert Terraform JSON to YAML — Free Online Converter

Last updated: April 2026 6 min read
Quick Answer

Table of Contents

  1. Variable files — JSON to YAML
  2. Plan and state dumps for review
  3. Output values — JSON to YAML for docs
  4. Terraform doesn't consume YAML natively
  5. When to use jq instead
  6. Frequently Asked Questions

Terraform's native language is HCL, but it also accepts JSON for modules, reads JSON variable files with -var-file=vars.json, and emits JSON from terraform show -json and terraform output -json. Converting those JSON artifacts to YAML makes them easier to review, document, and share. This guide covers the common Terraform JSON-to-YAML scenarios.

Variable Files — JSON to YAML

Terraform's -var-file flag accepts JSON, but your team may prefer YAML for vars that are edited by humans. Convert with the browser tool:

// terraform.tfvars.json
{"region":"us-east-1","instance_count":3,"tags":{"env":"prod","owner":"platform"}}

After conversion:

region: us-east-1
instance_count: 3
tags:
  env: prod
  owner: platform

Note: Terraform doesn't natively read YAML vars. You'd convert YAML back to JSON (or HCL) before running terraform apply. The YAML is for Git readability and reviews.

Plan and State Dumps for Review

terraform show -json plan.tfplan emits a huge JSON. For PR reviews showing "this is what will change," converting to YAML makes the diff far more readable.

Workflow:

  1. terraform show -json plan.tfplan > plan.json
  2. Paste into our converter.
  3. Paste the YAML into a PR comment or attach to a review.

This isn't the recommended production review tool — terraform show plan.tfplan (text) is usually better. But for some workflows (like non-engineer stakeholders), YAML is more approachable than HCL diff output.

Sell Custom Apparel — We Handle Printing & Free Shipping

Output Values — JSON to YAML for Docs

terraform output -json dumps all outputs as JSON. Convert to YAML for README snippets:

// Input
{"api_endpoint":{"value":"https://api.example.com","type":"string"},"vpc_id":{"value":"vpc-0abcd","type":"string"}}

YAML:

api_endpoint:
  value: https://api.example.com
  type: string
vpc_id:
  value: vpc-0abcd
  type: string

Paste into a docs file. Reviewers see what the stack produced without needing to run Terraform themselves.

Terraform Doesn't Consume YAML Natively

Worth being clear: Terraform's input formats are HCL and JSON. It does not read YAML for configurations, variables, or any other purpose. So the workflow is always one-directional — JSON output from Terraform flows into YAML for human review.

If you want YAML as a source of truth (edit YAML, generate Terraform), you'd need a wrapper layer — a script that reads YAML and emits HCL or JSON. Common approach: use a config generator like cdktf or Pulumi, or a template engine like Jinja2 wrapping YAML.

When to Use jq Instead

If you only need to extract specific values from Terraform JSON (not convert the whole thing), jq is the right tool:

terraform output -json | jq -r '.api_endpoint.value'

Use our converter when you want the whole structure as YAML. Use jq when you want specific fields. They complement each other — common pattern is jq to filter, then paste the filtered JSON into the converter for YAML output.

Readable Terraform Artifacts in YAML

Paste terraform output JSON, click Convert, share YAML that reviewers actually read.

Open Free JSON to YAML Converter

Frequently Asked Questions

Can Terraform read YAML variable files?

No. Terraform accepts HCL and JSON for tfvars. YAML isn't supported natively. If you want YAML as a source of truth, wrap it with a script that converts to JSON before terraform apply.

Is there a tool that converts HCL to YAML?

Not directly — HCL is a distinct language. You'd go HCL → JSON (via terraform show -json or hcl2json) → YAML (via our converter). Two-step process.

What about cdktf or Terraform CDK configs?

CDKTF uses TypeScript, Python, Go, or Java to emit Terraform JSON. The emitted JSON can be converted to YAML for review. For config-as-code with YAML input, you'd need to build a wrapper over CDKTF.

Will conversion preserve Terraform-specific types like maps and lists?

Yes — Terraform JSON uses standard JSON objects and arrays, which map cleanly to YAML dicts and lists. Structure is preserved identically.

Alicia Grant
Alicia Grant Frontend Engineer

Alicia leads image and PDF tool development at WildandFree, specializing in high-performance client-side browser tools.

More articles by Alicia →
Launch Your Own Clothing Brand — No Inventory, No Risk