Back to index

Best diagram-as-code tools in 2025

Shin Kim

@ Eraser

What is diagram-as-code?

Diagram-as-code is a text-first way to create diagrams. Instead of dragging shapes, you write a simple syntax that lists each node, the relationships between them, and any optional styling. A rendering engine then turns that syntax into a visual image on demand, so the diagram can be regenerated anywhere the renderer runs. By separating the diagram’s logical model from its presentation – much like infrastructure-as-code separates cloud resources from the scripts that define them – this approach keeps diagrams portable, deterministic, and easy to share.

Why use diagram-as-code?

  • AI-powered diagram creation: Diagram-as-code has surged in popularity because large language models (LLMs) excel at generating diagram syntax from natural language prompts. This integration makes it effortless to produce accurate diagrams rapidly and with minimal effort.
  • Automated, clean layouts: Manually positioning and aligning elements in a diagram can be tedious and error-prone. Diagram-as-code automatically arranges diagram components, enabling you to concentrate on content and relationships rather than the mechanics of layout.
  • Seamless code integration: With diagram-as-code, diagrams integrate smoothly into your existing software development practices. You can leverage version control systems like Git to easily track changes, manage revisions, and perform diffs—aligning visual documentation perfectly with your development workflow.

What are the best diagram-as-code tools?

Comparison of the best diagram-as-code tools in 2025

Eraser

  • Features
    • Presentation-quality diagrams with polished visuals
    • Simple, intuitive syntax
    • Extensive icon library for various use cases
    • Integrated web and AI editors on eraser.io
    • Seamless integration of drag-drop and syntax-based edits
    • API availability for automation and integration
  • Who it's for
    • Teams embracing AI-driven diagramming workflows
    • Organizations seeking consistent, standardized documentation
  • Limitations
    • Proprietary (not open source)

Mermaid

  • Features
    • Open-source (MIT License)
    • Broad variety of supported diagram types
    • Built-in rendering support on GitHub and GitLab READMEs
  • Who it's for
    • Developers embedding diagramming functionality in products
    • Teams looking for self-hosted, open-source diagramming solutions
  • Limitations
    • Complex syntax; learning curve involved
    • Basic, minimalistic rendering style
    • Drag-drop edits incompatible with code-based edits

PlantUML

  • Features
    • Comprehensive support for official UML diagram standards
    • Extensive diagram type coverage
  • Who it's for
    • Teams requiring strict UML specification adherence
  • Limitations
    • Steeper learning curve due to complex syntax
    • Minimal visual polish in rendering
    • No cloud-hosted option to save or manage diagrams centrally

D2

  • Features
    • Feature-rich, user-friendly web editor
    • Compability between drag-drop and syntax-based edits
    • Unified syntax applicable across all diagram types
    • Specialized features like animation and LaTeX support
  • Who it's for
    • Teams desiring an integrated, flexible diagram-as-code experience
    • Teams not prioritizing AI-driven diagramming
  • Limitations
    • No integrated AI features for diagram generation or editing

Diagram (Python library)

  • Features
    • Open-source (MIT License)
    • Extensive icon set focused on cloud service providers
  • Who it's for
    • Developers automating diagram generation in CLI or CI/CD pipelines
  • Limitations
    • Lacks a web-based visual editing interface
    • Can only be used as a Python library
    • Limited scope; supports only cloud architecture diagrams

What features to look for

Core syntax and engine

  • Syntax simplicity: Syntax complexity can greatly impact how easily your team adopts a diagram-as-code tool. Lightweight syntax – like that of Eraser – enables first-time users to quickly grasp diagramming concepts without friction. More complex syntaxes (e.g., Mermaid or PlantUML), while potentially more expressive, may pose barriers for non-technical team members. Simple syntaxes also tend to be more error-free when generated using AI.
  • Visual polish: Diagrams typically need to professional and presentable, whether for internal communication, client presentations, or public-facing content. Important visual considerations include:
    • Clean and professional output
    • Readability and clarity of layout
    • Suitability for standard presentation formats (slides, pages)
    • Support for drag-drop layout adjustments
    • Styling options

Editor capabilities

  • AI editing: Strong AI integration significantly boosts productivity by automating diagram creation and editing. Evaluate AI capabilities based on how accurate, quick, and comprehensive they are, enabling you to iterate and refine diagrams with minimal effort.
  • Drag-drop editing: When precise control over diagram layout is essential, look for tools that support intuitive drag-drop editing alongside code-based edits. Ideally, edits via drag-drop should seamlessly integrate with diagram-as-code, preserving the flexibility of combined editing modes (e.g., Eraser supports composable drag-drop and code editing).

Workflow integration

  • Supported platforms: Consider your team's day-to-day workflow. Most teams prioritize diagramming tools with robust web application. Depending on your specific needs, also evaluate availability of API support, IDE extensions, CLI utilities, and CI/CD integration.
  • Open source availability: Although less common, an open-source tool offers unique benefits, particularly:
    • Self-hosting capability: Important if your organization operates in tightly controlled or isolated IT environments.
    • Full code access: Ideal for developers who plan to customize or incorporate the diagramming engine directly into their own products or workflows.

How to pick a diagram-as-code tool

  • Clarify your primary use case: Before diving into the specifics of different diagram-as-code solutions, clearly identify your primary use case, target users, and desired outcomes. The ideal tool varies significantly based on your scenario—whether you're a consulting firm aiming to streamline AI-driven diagram creation for client presentations, or a financial institution looking to self-host a secure, offline solution for generating diagrams from legacy systems.
  • Evaluate with hands-on testing: Most diagram-as-code solutions offer online playgrounds or trial environments. Use these to experiment directly by creating diagrams via code or AI prompts, helping you quickly assess usability, layout quality, and integration capabilities without extensive setup.

Final thoughts

Diagram-as-code streamlines the process of creating clear, consistent, and easily maintainable diagrams, especially as teams increasingly embrace AI-driven workflows. By carefully considering your team's specific needs, testing tools firsthand, and prioritizing key features such as syntax simplicity, visual polish, AI integration, and workflow compatibility, you can confidently choose the ideal diagram-as-code solution for your organization.