# HCL-JSON Converter

Convert between HashiCorp Configuration Language (HCL) and JSON formats for Terraform configurations

> Canonical page: https://test.elysiatools.com/en/tools/hcl-json-converter

- **Category:** Format Conversion

- **Keywords:** hcl, hashicorp, terraform, json, convert, transform, hcl converter, json to hcl, hcl to json, config, configuration

## Overview

The HCL-JSON Converter is a specialized utility designed to seamlessly transform configuration files between HashiCorp Configuration Language (HCL) and JSON, ensuring compatibility for your Terraform infrastructure projects.

## Inputs

- **Input Data** (textarea): Enter HCL or JSON data...
- **Conversion Direction** (select)
- **JSON Indent Size** (number): Enter JSON indent size (1-8)

## When to use

- When you need to integrate Terraform configurations with automated tools that only support JSON.
- When migrating legacy JSON-based infrastructure definitions into standard HCL format.
- When you need to validate or inspect complex HCL structures by viewing them in a machine-readable JSON format.

## How it works

- Paste your HCL or JSON configuration code into the input area.
- Select the desired conversion direction (HCL to JSON or JSON to HCL).
- Adjust the JSON indent size if necessary to match your project's style guide.
- Click the convert button to generate and copy your transformed configuration.

## Use cases

- Standardizing infrastructure-as-code repositories by converting legacy JSON configs to HCL.
- Generating dynamic Terraform variables using external scripts that output JSON.
- Debugging complex HCL files by converting them to JSON to check for structural errors.

## Frequently asked questions

### Is this tool compatible with all Terraform versions?

Yes, the converter handles standard HCL and JSON syntax used across all major Terraform versions.

### Can I convert multiple files at once?

This tool is designed for individual configuration blocks; please process files one at a time.

### Does the tool store my configuration data?

No, all conversions are performed locally in your browser, and your data is not stored or transmitted.

### What is the purpose of the JSON Indent Size option?

It allows you to control the readability of the output JSON by setting the number of spaces used for indentation.

### Will comments in HCL be preserved in JSON?

JSON does not support comments; therefore, any comments present in your HCL input will be removed during the conversion to JSON.

## Related tools

- [Text to Excel Converter](https://test.elysiatools.com/en/tools/text-to-excel): Paste CSV, TSV, JSON, key-value, or INI text and download a formatted XLSX spreadsheet
- [CSV to JSON Converter](https://test.elysiatools.com/en/tools/csv-to-json): Convert CSV data to JSON format with customizable parsing options
- [Excel to JSON Converter](https://test.elysiatools.com/en/tools/excel-to-json): Convert Excel file to JSON format, extracting data from the first worksheet
- [TOML-JSON Converter](https://test.elysiatools.com/en/tools/toml-json-converter): Convert between TOML and JSON formats with support for comments and complex data structures
- [YAML-JSON Converter](https://test.elysiatools.com/en/tools/yaml-json-converter): Convert between YAML and JSON formats
- [Markdown Table to CSV JSON with Type Inferred Schema](https://test.elysiatools.com/en/tools/markdown-table-to-csv-json-schema): Convert a Markdown pipe table to CSV, JSON rows or an inferred JSON Schema with alignment and null diagnostics
- [Text to JSON Converter](https://test.elysiatools.com/en/tools/text-to-json): Convert various text formats to JSON with customizable parsing options
- [TOML / INI / HCL / .env / Nix / dotenv ⇄ Kubernetes ConfigMap & Secret Config Format Bridge](https://test.elysiatools.com/en/tools/toml-ini-hcl-envfile-nix-dotenv-kubernetes-configmap-secret-config-format-bridge): Convert configuration files between dotenv .env, TOML, INI, Java .properties, YAML, JSON, HCL (Terraform/Vagrant native syntax) and Nix attribute sets, and emit Kubernetes ConfigMap or Secret manifests. Template placeholders (${VAR}, {{var}}, envsubst) are preserved verbatim, type inference provenance (string/int/float/bool/list) is tracked, HCL block labels fold into nested keys, and a round-trip diff calls out non-equivalent settings — dropped keys, re-typed values and rewrites — instead of coercing them silently.

## Samples

- [Terraform Plan JSON Samples](https://test.elysiatools.com/en/samples/terraform-plan-json-samples): Sample Terraform plan JSON files exported from terraform show -json style payloads for dependency visualization and change review
- [Chat Transcript JSON Samples](https://test.elysiatools.com/en/samples/chat-transcript-json): JSON examples for multi-role chat transcripts
- [Rich Media JSON Samples](https://test.elysiatools.com/en/samples/rich-media-json): JSON examples for popular rich text editors (TipTap, Quill, Slate)
- [JSON Samples](https://test.elysiatools.com/en/samples/json): JSON (JavaScript Object Notation) format examples from simple to complex structures

## Related content

- [Environment and Configuration Format Workflow](https://test.elysiatools.com/en/hubs/config-workflows): Inspect, validate, convert, merge, and diff configuration without exposing secrets or losing the source of truth.
- [JSON Normalization and Interchange Workflow](https://test.elysiatools.com/en/hubs/json-convert): Turn a structured source into a checked JSON representation, then export the exact table, configuration, document, API, XML, CSON, EDN, BSON, or UBJSON form required downstream.
