# HCL-JSON Converter

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

> Canonical page: https://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://elysiatools.com/en/tools/text-to-excel): Convert various text formats to Excel with customizable parsing and formatting options
- [CSV to JSON Converter](https://elysiatools.com/en/tools/csv-to-json): Convert CSV data to JSON format with customizable parsing options
- [Excel to JSON Converter](https://elysiatools.com/en/tools/excel-to-json): Convert Excel file to JSON format, extracting data from the first worksheet
- [TOML-JSON Converter](https://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://elysiatools.com/en/tools/yaml-json-converter): Convert between YAML and JSON formats
- [Markdown Table to CSV JSON with Type Inferred Schema](https://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://elysiatools.com/en/tools/text-to-json): Convert various text formats to JSON with customizable parsing options
- [BOM Character Remover](https://elysiatools.com/en/tools/data-bom-remover): Remove BOM (Byte Order Mark) characters from text and file content. Perfect for cleaning up text files that have encoding issues, fixing CSV imports, and preparing data for processing. Features: - Detect and remove UTF-8 BOM (EF BB BF) - Detect and remove UTF-16 BOM (FE FF or FF FE) - Detect and remove UTF-32 BOM (00 00 FE FF or FF FE 00 00) - Support multiple input formats - Visual BOM character display - Detailed detection report - Support for batch text processing Common Use Cases: - Fix CSV file import errors - Clean up text file encoding issues - Prepare data for JSON parsing - Fix XML parsing problems - Resolve API data encoding conflicts - Standardize text data format

## Samples

- [Terraform Plan JSON Samples](https://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://elysiatools.com/en/samples/chat-transcript-json): JSON examples for multi-role chat transcripts
- [Rich Media JSON Samples](https://elysiatools.com/en/samples/rich-media-json): JSON examples for popular rich text editors (TipTap, Quill, Slate)
- [JSON Samples](https://elysiatools.com/en/samples/json): JSON (JavaScript Object Notation) format examples from simple to complex structures

## Related content

- [JSON Interchange and Format Translation Tools](https://elysiatools.com/en/hubs/json-convert): Compare JSON conversion tools for CSV, YAML, TOML, GraphQL, XML, Markdown, Excel, BSON, EDN, and related structured formats in one hub.
- [Configuration File Conversion and Environment Diff Tools](https://elysiatools.com/en/hubs/config-workflows): Parse .env files, convert YAML/TOML/HCL configs, merge config fragments, and compare environment drift in one configuration workflow hub.
- [Text Case, Encoding, and Normalization Conversion Tools](https://elysiatools.com/en/hubs/text-convert): Compare text case conversion, character-width conversion, encoding conversion, quoted-printable handling, and inline text normalization tools in one hub.
- [JSON Inspection, Diff, and Transformation Tools](https://elysiatools.com/en/hubs/json-utility): Compare JSON formatting, diffing, path inspection, schema validation, merging, transformation, and export tools in one hub for API and data workflows.
