All Tools View Categories About Contact Privacy

Terraform Diagram as Code Generator

Generate a Mermaid diagram of resources and references from your .tf.

Runs entirely in your browser - nothing is uploaded and no cloud connection is made.
Your Mermaid diagram will appear here.

About Terraform Diagram as Code Generator

The Terraform Diagram as Code Generator turns a pasted Terraform configuration into a Mermaid diagram, so you can visualize resources and the references between them without leaving your browser. Each resource becomes a node, and whenever one resource refers to another, such as a bucket referencing aws_s3_bucket.this.id, an edge is drawn between the two nodes.

The generator parses your .tf with a built-in HCL parser, so there is no need to install Terraform or graphviz. The output is plain Mermaid text that you can drop into any Mermaid editor, a GitHub Markdown code block, or a documentation site. Because everything runs locally, your configuration is never uploaded and no cloud account is required. It is a quick way to explain a module to a teammate, to sanity-check that references line up the way you expect, or to include a diagram in a README that updates as the code changes.

Diagrams also help during incident response and onboarding. When something breaks, a current graph of resource relationships lets an on-call engineer see what depends on what without reading hundreds of lines of HCL. New teammates can grasp the shape of a system in seconds, and the visual makes gaps, such as an unreferenced security group, easy to notice at a glance. Because the diagram is regenerated from the code, it never drifts from reality the way a hand-drawn picture eventually does.

For larger systems the graph doubles as a review aid. Reviewers can skim the node and edge list to confirm that a proposed change only touches the resources it should, and that no unexpected cross-module dependency is being introduced. That context is hard to get from a diff alone, especially when resources are defined far apart in the file tree.

Features

  • Resource nodes - one node per resource in the configuration.
  • Reference edges - inferred from attribute references between resources.
  • Mermaid output - drop the text into any Mermaid renderer.
  • Built-in HCL parser - no Terraform install required.
  • Direction control - a top-down graph that reads cleanly.
  • Client-side only - parsed in your browser.
  • Copy, download and print - export the diagram as .mmd.
  • No cloud connection - paste .tf and read the result locally.
  • Private - your configuration never leaves the page.
  • Shareable - embed the diagram in docs or pull requests.
  • Onboarding aid - new engineers grasp systems quickly.
  • Gap spotting - orphaned or unreferenced resources stand out.
  • Review aid - confirm a change only touches what it should.
  • Drift free - the picture is always generated from real code.

How to Use

  1. Open the generator and locate the Terraform input box on the left.
  2. Paste your .tf configuration that contains resource blocks.
  3. Click Generate diagram to build the Mermaid graph.
  4. Review the nodes to confirm every resource appears.
  5. Review the edges to confirm the references look correct.
  6. Export the output with Copy, Download as .mmd, or Print.
  7. Start over with Clear, or load a sample with Load sample.
  8. Render it by pasting the Mermaid text into a Mermaid editor or Markdown block.
  9. Iterate by editing the .tf and regenerating until the diagram matches your mental model.

Examples

Example - bucket and policy. An aws_s3_bucket named this referenced by an aws_s3_bucket_policy named this via bucket = aws_s3_bucket.this.id produces two nodes with an edge from the bucket to the policy, making the dependency obvious at a glance.

Example - multiple resources. Paste several resources that reference each other and the graph shows the full dependency web, which is useful for spotting circular or missing links before you apply.

Example - module boundaries. Resources inside different modules that still reference each other across module boundaries show up as edges, which helps you see hidden coupling that a module listing alone would hide. This is often the most valuable insight the diagram reveals.

Benefits

  • Quick maps - visualize configurations in seconds.
  • Portable - Mermaid renders almost anywhere.
  • Safe - no uploads and no cloud connection.
  • Educational - see how references become edges.
  • Doc ready - embed diagrams in READMEs.
  • Private - configuration stays in the browser.
  • Incident ready - reason about dependencies under pressure.
  • Drift free - always generated from the real code.
  • Lightweight - no extra tooling beyond a Mermaid renderer, keeping your diagram pipeline simple and fast.

Frequently Asked Questions

What input does it take?
Paste any Terraform .tf that contains resource blocks. It is parsed locally with a built-in HCL parser.
How are relationships drawn?
When one resource references another (for example bucket = aws_s3_bucket.this.id) an edge is drawn between them.
Does it draw providers?
This tool focuses on resource blocks and their references. Provider-level flows live in the architecture diagram tool.
Where can I render the output?
Any Mermaid editor or a mermaid code block in Markdown.
Is anything uploaded?
No. Everything runs in your browser.