How to Convert TOML to HCL
Add Your TOML Configuration
Paste your TOML configuration or upload a .toml file. Anything in TOML v1.0.0 is read the same way: tables, arrays of tables, inline tables and nested keys.
Read the HCL
Shortly after you stop typing, the file is parsed and written as HCL, the configuration language Terraform, Vault and other HashiCorp tools read. Each table becomes a name = { ... } map and each array of tables becomes a list of objects:
[database] host = "localhost" port = 5432 [[services]] name = "api" port = 8080
database = {
host = "localhost"
port = 5432
}
services = [
{
name = "api"
port = 8080
},
]Copy or Download HCL
Copy the converted HCL to your clipboard or download it as a .hcl file for use in your projects.
Frequently Asked Questions
Why convert TOML to HCL?
Mostly to reuse values that already live in a TOML file inside HashiCorp tooling. A Cargo.toml, a Hugo config or an application’s settings can be turned into HCL attributes and dropped into a .tfvars file or a locals block, which is quicker than retyping a long table by hand.
How are tables and arrays of tables written in HCL?
A table such as [database] becomes database = { ... }, an attribute whose value is an HCL object. An array of tables, [[services]], becomes a list of objects: services = [ { ... }, { ... } ]. Inline tables and plain arrays keep their shape, so a reader like hashicorp/hcl gets back the same structure it would from the original TOML.
Are numbers, dates and strings kept exactly?
Numbers are copied, not retyped: 8901240544102066246 and -9223372036854775808 stay bare HCL integers with every digit, and 14.50 keeps its trailing zero. A value with a leading zero such as 00501 is already a quoted string in TOML, so it stays a string. HCL has no date or infinity type, so dates, inf and nan are written as strings. Hex, octal and binary integers (0xFF, 0o17) come out as their decimal value. Strings are escaped so each one stays on a single line.
What happens if my TOML has a mistake?
Nothing is written. You get the line and column of the first problem with the line shown underneath, for example a key with = but no value, or text that is missing its quotes. If you paste JSON or YAML by mistake, the page says which format it looks like and points you to the right converter.
Does this produce Terraform resource blocks?
No. The output is plain HCL: attributes, nested { } maps and [ ] lists, not resource "aws_instance" "web" { } blocks, because a TOML table carries no block type or labels to build those from. It is well suited to variable values, locals and general HCL config. To go from Terraform JSON to .tf, use the JSON to HCL converter instead.
Is my TOML uploaded anywhere?
No. The TOML is parsed and converted in your browser, so the file you paste or upload stays on your own machine and is never sent to a server. Nothing is kept either: reload the page and the editor starts empty.
Going the other way? The HCL to TOML converter turns HCL back into TOML. For Terraform JSON use JSON to HCL, and YAML to HCL does the same job starting from YAML.
Related Tools
HCL to JSON
Convert HashiCorp Configuration Language (Terraform) to JSON format
JSON to HCL
Convert JSON to HashiCorp Configuration Language for Terraform
HCL Formatter
Format and beautify HCL/Terraform configuration files with proper indentation
HCL Validator
Validate HCL/Terraform syntax and structure with error detection
HCL Fixer
Fix broken HCL/Terraform files automatically, repair syntax errors, missing braces, and malformed blocks
HCL to YAML
Convert Terraform HCL configuration to YAML format