When would I convert JSON to HCL?
Two scenarios. First, you have generated configuration as JSON (from a script, an API, or a JSON-based tool) and want to commit it as readable .tf source. Second, you are migrating from a JSON-driven configuration system (cloud control planes, REST APIs) to Terraform and want a starting point in HCL.
How does it decide between blocks and attributes?
Object values become blocks; primitive values become attributes; arrays of primitives become inline lists; arrays of objects become repeated blocks with the same name. The serializer also collapses nested single-key objects into labeled blocks — for example { resource: { aws_s3_bucket: { example: {...} } } } becomes resource "aws_s3_bucket" "example" { ... }, the standard Terraform convention.
What if my JSON keys contain dashes or special characters?
Keys that are not valid HCL identifiers (must start with a letter or underscore, followed by letters/digits/underscores/hyphens) are automatically wrapped in double quotes. The output stays valid HCL — Terraform accepts quoted attribute names.
Can I round-trip — HCL → JSON → HCL?
For static configuration, yes. The pair of converters preserves blocks, labels, attributes, lists, and maps. Comments are not preserved (JSON has no comment syntax) and whitespace is normalised. Interpolation strings (${...}) round-trip as-is because both directions treat them as plain strings.
Will the output run with terraform fmt?
Yes. The serializer uses 2-space indentation and standard block layout. Running terraform fmt on the result is a no-op for most cases — it may align trailing equals signs in attribute groups, which is purely cosmetic.
What about HCL functions and expressions?
JSON has no notion of function calls (lookup, format, jsonencode), so any computed expression must be encoded as a string in the JSON input — typically using interpolation syntax: "value": "${lookup(var.map, "key")}". The serializer emits that string verbatim, and Terraform evaluates the expression at plan time.
Is my JSON uploaded?
No. Parsing and serialisation happen entirely in JavaScript inside your browser. Configuration with cloud account IDs, ARNs, or project names never touches a server. You can verify in DevTools → Network — clicking Convert produces zero HTTP requests.
Can Terraform also read .tf.json directly?
Yes — that is what your input already is. Use this converter when you want a human-friendly .tf file instead. JSON is best for machine-generated configuration; HCL is best for hand-edited modules and pull-request review.