HCL to JSON
Convert Terraform-style HCL configuration into equivalent JSON.
HCL to JSON
Paste HCL — the language Terraform, Packer and other HashiCorp tools use — and this converter returns the equivalent JSON. It handles the everyday shapes of a real .tf file: top-level attributes, and blocks with zero or more string labels such as resource "aws_instance" "web", nested inside other blocks as deep as your config goes. Labeled blocks convert using the same convention Terraform's own .tf.json syntax uses, so a resource with a type and a name lands under resource → type → name in the result, and repeated blocks at the same path — two ingress blocks inside one resource, say — become a JSON array instead of overwriting each other.
Strings, numbers, booleans, null, lists and inline object literals (tags = { Name = "web" }) all convert directly. Heredoc strings (<<EOT ... EOT and the indented <<-EOT form) become plain JSON strings with their line breaks kept, and ${var.name} interpolations — along with bare references like var.region or a call such as merge(a, b) — stay as literal text rather than being evaluated, since no browser tool can resolve Terraform variables or providers.
Options cover indent width (2 spaces, 4 spaces, tabs or minified), sorting keys alphabetically, keeping or discarding comments, and choosing between one merged JSON object or a flat list of blocks — each with its type, labels and body — for easier scripting. Duplicate attribute keys inside a block are flagged in the live tally rather than silently dropped, and Windows and Unix line endings are both accepted.
Everything runs locally in your browser — your configuration is never uploaded, which matters when it names real resources, IPs or account IDs. Copy the JSON, download it as a .txt file, or send it straight into another tool to keep working.