All Tools View Categories About Contact Privacy

Terraform Variable Generator

Build a single Terraform variable block (HCL) for variables.tf.

Runs entirely in your browser - nothing is uploaded and no cloud connection is made.
0
attributes
Your generated variable block will appear here.

About Terraform Variable Generator

Input variables are how a Terraform module accepts configuration from the outside world, and a clean variable block is the foundation of any reusable module. The Terraform Variable Generator builds one correct variable block from a simple form, sparing you from remembering the exact attribute order and quoting rules.

You provide a name and a type, optionally a default together with its literal type, a description, and the sensitive and nullable flags. When you choose the custom type you can paste any type expression, from a list to a complex object. Names are validated as Terraform identifiers before output is produced, and the default is always formatted as the correct HCL literal for its type.

Everything is assembled locally in your browser; nothing is uploaded and no cloud connection is made. The generated block drops straight into variables.tf, and because the output is formatted like terraform fmt you can commit it without extra cleanup. Well-defined variables are also what make terraform docs output useful, since each description becomes searchable documentation for the people who consume your module.

Using this generator also helps enforce team standards, because every variable is produced the same way with descriptions and types filled in, rather than left as a bare name that nobody understands six months later.

Features

  • Common types - string, number, bool, list(any), map(any), set(string) and a custom type you type yourself.
  • Custom type support - paste any type expression such as object({ name = string }) when the presets are not enough.
  • Typed default literals - the default is emitted as the right HCL literal, with strings quoted and numbers left bare.
  • Description field - document each input so editors and terraform docs show helpful text.
  • Sensitive flag - mark secret values to redact them in plan and apply output.
  • Nullable flag - emit nullable = false to disallow null values explicitly.
  • Identifier validation - variable names are checked against Terraform naming rules.
  • Consistent ordering - attributes are always emitted in the same order for easy review.
  • Team standards - generating every variable the same way encourages descriptions and types that would otherwise be skipped.
  • Copy and download - export the block as HCL, a file or printed output.
  • Review friendly - predictable output makes code review faster because every block looks the same.

How to Use

  1. Name the variable - type an identifier such as db_password or instance_count.
  2. Pick a type - choose a common type or select custom and type your own expression.
  3. Set a default - optionally enter a default value and pick its literal type so it is formatted right.
  4. Add a description - write a short sentence explaining what the variable controls.
  5. Toggle flags - mark the variable sensitive for secrets and nullable = false where null is not allowed.
  6. Generate the block - press "Generate HCL" to validate the name and assemble the block.
  7. Export it - Copy the HCL, Download variables.tf, or Print the result for your records.

Examples

Example - sensitive password. name=db_password, type=string, sensitive=true yields a variable whose value Terraform redacts in plan output, protecting credentials from logs.

Example - number with default. name=port, type=number, default=8080 emits type = number and default = 8080 without quotes.

Example - custom object. A custom type such as object({ name = string, count = number }) is emitted verbatim, enabling strongly typed module inputs.

Example - list of subnets. name=subnets, type=list(string), default=["subnet-a", "subnet-b"] produces a typed list default that validates cleanly.

Example - boolean flag. name=enabled, type=bool, default=true emits type = bool and default = true, useful for feature toggles.

Benefits

  • Correct schema - the block follows the variable specification exactly.
  • Typed defaults - defaults are emitted as valid HCL literals, never as raw text.
  • Secret safe - the sensitive flag keeps credentials out of logs.
  • Validated names - bad identifiers are caught before output is generated.
  • Private - the entire tool runs in your browser.
  • Custom friendly - any type expression is accepted, so advanced modules are supported.
  • Self-documenting - descriptions turn variables into readable module documentation.
  • Instant export - copy, download or print the block in one click.
  • Fewer mistakes - automatic formatting removes quoting and indentation errors before they reach a plan.
  • Consistent modules - uniform variables make a collection of modules feel like one coherent system.

Frequently Asked Questions

What does this tool generate?
It writes one variable block with the name, type, optional default, description and sensitive/nullable flags.
Which types are supported?
string, number, bool, list(any), map(any), set(string) and a custom type you type yourself.
How is the default formatted?
The default is emitted as the HCL literal matching the default type you choose (string, number, bool or raw).
Does this connect to a cloud?
No. Everything is assembled in your browser and nothing is uploaded.
Can I download it?
Yes. Copy the HCL, download variables.tf, or print it.