All Tools View Categories About Contact Privacy

Terraform Lint / Format Previewer

Preview how terraform fmt would normalize your .tf, with a changed flag and line counts.

Runs entirely in your browser - nothing is uploaded and no cloud connection is made.
no
would reformat
0
formatted lines
0
blocks
Your formatted preview will appear here.

About Terraform Lint / Format Previewer

The Terraform Lint / Format Previewer is a private, browser-only utility that shows how the terraform fmt command would rewrite your configuration before you ever run it in a terminal. When teams collaborate on infrastructure as code, formatting drift is inevitable: different editors insert different indentation, trailing whitespace, quote styles and brace placement, and pull requests quickly fill with noise that has nothing to do with the actual change. This previewer parses the pasted HCL with the same structural model Terraform uses and re-emits it in canonical, two-space-indented form so you can see exactly what a formatter would produce.

Beyond the normalized text, the tool reports a clear changed flag so you know at a glance whether the code would be rewritten, and it counts the original and formatted line totals so you can gauge the size of the layout shift. Because everything runs locally in your browser, no configuration, secrets, variable values or resource addresses ever leave the page. It is ideal for code review, for teaching contributors the canonical HCL style, and for quickly normalizing a snippet copied from a blog post or chat message before pasting it into a module.

The previewer is also useful as a sanity check before committing: paste a file from a teammate and confirm whether the formatter would touch it, which tells you whether review comments about style are even warranted. It complements linters that check deeper correctness, focusing purely on presentation so the two tools stay complementary rather than overlapping.

Features

  • Normalized preview - canonical two-space HCL so you see exactly what a formatter would emit.
  • Changed flag - a clear YES or no indicator telling you whether fmt would rewrite the file.
  • Line counts - original versus formatted totals for a quick sense of the layout shift.
  • Block inventory - the number of resource, data, variable, output, module and provider blocks detected.
  • Parse safety - malformed HCL is caught and reported with a readable message instead of failing silently.
  • One-click sample - load a realistically messy snippet to see the formatter in action instantly.
  • Example presets - choose from several realistic inputs to compare formatting outcomes.
  • Word-wrap toggle - switch the preview between scroll and wrapped so long lines stay readable.
  • Export - copy the formatted HCL, download it as a .tf file, or print it for review.
  • Markdown copy - copy a fenced-code-block version ready to paste into a pull request comment.
  • Theme aware - the panel ships its own scoped styles so it renders correctly inside a light or dark host page.
  • Keyboard friendly - every control is a real button or input that works without a mouse.
  • Private - nothing is uploaded and no network connection is made at any point.

How to Use

  1. Paste your .tf - drop the Terraform configuration you want to inspect into the input box on the left.
  2. Load an example - pick a preset or click Load sample to fill the box with a deliberately messy snippet.
  3. Toggle word wrap - turn on wrapping if the preview has long lines you want to keep on screen.
  4. Click Preview - the tool parses the HCL and renders the canonical formatted output on the right.
  5. Read the stats - check the changed flag, the line counts and the detected block inventory.
  6. Review any error - if the HCL does not parse, an inline message explains what to fix.
  7. Export the result - copy the HCL, copy it as Markdown, download a .tf, or print it.
  8. Clear and repeat - wipe the input and run another file whenever you like.

Examples

Example. Paste a resource written on a single ragged line, such as resource "aws_instance" "web"{ ami="ami-12345678" instance_type="t2.micro" }. The previewer emits the canonical block with each attribute on its own line, two-space indentation, and spaces around the equals signs. The changed flag reads YES, the block inventory shows one resource, and the line counts rise from one original line to several formatted lines. Copy that output straight into your module and your next terraform fmt will be a no-op.

The same flow works for an entire module: paste several interleaved resource, data and output blocks and the inventory stat reports the total block count, giving you a one-glance complexity signal before review.

Benefits

  • Fast feedback - see the formatted result in milliseconds without installing Terraform.
  • Review hygiene - catch formatting noise before it reaches a pull request.
  • Safe - no secrets or state ever leave your browser.
  • Teaching aid - show new contributors exactly what canonical HCL looks like.
  • Portable output - export as HCL, Markdown, a file or a printout.
  • Complementary - pairs cleanly with deeper linters that check semantic correctness rather than style.

Frequently Asked Questions

How is this different from the fmt checker?
The fmt checker reports whether formatting would change; this previewer focuses on showing the normalized output and line-change counts for a quick visual review.
Does it modify my file?
No. It only displays the preview - nothing is written or uploaded.
Is it a full terraform fmt?
It is a close client-side approximation that normalizes indentation and spacing; it may not match every Go formatter nuance.
Why show line counts?
A quick signal of how much the layout would shift after formatting.
Can I export the preview?
Yes. Copy, download as .tf, or print.