← Back to Blog

Mastering Mermaid: Tips for Customizing Auto-Generated Diagrams

ArchToCode Team May 26, 2026 8 min read
Mermaid diagramsdiagram customizationcode visualizationArchToCodeAI diagram generationMermaid stylingdiagram error recoverycode architecturesoftware documentationdeveloper toolsMermaid syntaxdiagramming best practices
Table of contents

In the world of software development, clarity is king. Understanding complex codebases, system architectures, and data flows is paramount for efficient development, onboarding, and documentation. This is where tools like ArchToCode shine, transforming your code into insightful, auto-generated Mermaid diagrams. But generating a diagram is just the first step; mastering its customization is where you truly unlock its power.

Mermaid, a JavaScript-based diagramming tool, uses a simple markdown-like syntax to create diagrams. ArchToCode leverages AI to generate this syntax directly from your code, offering a seamless visualization experience. However, an auto-generated diagram might not always perfectly align with your specific needs or aesthetic preferences. This article will guide you through advanced tips for customizing your Mermaid diagrams, ensuring they are not only accurate but also visually compelling and easy to understand.

Understanding ArchToCode's Customization Capabilities

ArchToCode isn't just about generating diagrams; it's about giving you control. The platform offers a rich suite of features designed to help you fine-tune every aspect of your visualizations. Before diving into specific Mermaid syntax, let's explore how ArchToCode empowers you:

  • Extensive Theming & Styling: With over 20 application themes and 22 Mermaid diagram styles, you can match your diagrams to your brand or personal preference. You can adjust font sizes, line curve styles, node spacing, and more.

  • Generation Settings Control: ArchToCode allows you to dictate the complexity and size of your diagrams. You can choose between 'Simple', 'Medium', or 'Complex' levels and set a 'Max Nodes' limit (5-50) to prevent overwhelming visualizations.

  • Display Options Toggles: Instantly simplify complex diagrams by toggling the visibility of arrows, containers, layers, edge labels, node labels, and even a mini-map. This client-side DOM manipulation provides flicker-free, instant updates.

  • Custom Prompt Templates: Beyond the 30+ built-in templates, you can create your own, defining specific instructions, diagram types, complexity levels, and even syntax safety rules like 'Avoid subgraphs' or 'Simple labels only'.

  • Error Recovery & Diagnosis: If Mermaid syntax errors occur, ArchToCode's comprehensive error panel provides AI-powered suggestions, editable parameters, and even an 'Explain Error' feature to help you understand and fix issues.

These features provide a powerful foundation for customization, allowing you to influence the AI's output and refine the visual presentation without manually editing every line of Mermaid code.

Tips for Customizing Auto-Generated Diagrams

1. Leverage ArchToCode's Generation Settings for Granular Control

One of the most effective ways to customize your diagrams is to influence the AI generation itself. ArchToCode's 'Generation Settings' in the right panel are your first line of defense against overly complex or simplistic diagrams.

  • Complexity Level: Start with 'Simple' for a high-level overview, then gradually increase to 'Medium' or 'Complex' as you need more detail. This directly impacts the AI's verbosity and the inclusion of elements like subgraphs.

  • Max Nodes: Use the slider to set a maximum number of nodes. This is crucial for maintaining readability, especially in large codebases. A diagram with too many nodes can be overwhelming.

  • Custom Instructions: When creating or editing a prompt, use the 'Custom Instructions' field to provide specific guidance to the AI. For example, you might write: "Focus on the main API endpoints and their direct dependencies, omitting utility functions." or "Group related components into subgraphs and label them clearly."

  • Syntax Safety Rules: Experiment with 'Avoid subgraphs' or 'Simple labels only' if you're encountering rendering issues or prefer a flatter diagram structure. These rules guide the AI to generate Mermaid code that adheres to your preferences.

After adjusting these settings, remember to click 'Apply & Regenerate' to see the changes reflected in your diagram. ArchToCode's intelligent caching system ensures that subsequent regenerations with similar settings are lightning-fast.

2. Master Display Options for On-the-Fly Simplification

Sometimes, you need to quickly adjust the visual density of a diagram without regenerating it. ArchToCode's 'Display Options' toggles are perfect for this. Located in the right panel, these options allow for instant, client-side manipulation of the SVG rendering.

  • Hide Containers: If your diagram uses subgraphs, hiding containers can reduce visual clutter, allowing you to focus on the relationships between individual nodes.

  • Hide Edge Labels: For diagrams with many connections and descriptive labels, turning off edge labels can make the overall flow easier to trace. You can always re-enable them for detailed inspection.

  • Show Layers: This subtle option applies a layered opacity effect, giving a sense of depth and hierarchy to your diagram. It's great for emphasizing the main components while still showing their connections to less critical elements.

  • Compact View: Need to fit more on the screen? The 'Compact View' reduces diagram spacing, offering a denser representation without losing information.

These toggles are invaluable for presentations or when you need to quickly switch between a detailed view and a high-level overview. The changes are instant and flicker-free, making for a smooth user experience.

3. Fine-Tune Aesthetics with Diagram Styles and Themes

Beyond structure and content, the aesthetic appeal of your diagrams plays a huge role in their effectiveness. ArchToCode provides extensive options to control the look and feel.

  • Application Themes: Explore the 20+ themes available under 'View' → 'Theme'. From 'Midnight' to 'Cyberpunk', these themes change the entire application's UI, including the accent colors used in your diagrams.

  • Diagram Styles: Under 'View' → 'Diagram Style', you'll find 22+ Mermaid style presets. Each preset offers a different combination of colors, fonts, and line styles.

  • Advanced Settings: For ultimate control, dive into the 'Advanced Settings' tab within 'Diagram Style'. Here, you can manually adjust:

    • Typography: Fine-tune font sizes, label padding, and more.

    • Layout: Experiment with 'Line Curve Style' (e.g., 'basis', 'linear', 'step') for different visual flows, or adjust 'Node Spacing' and 'Rank Spacing' to control diagram density.

    • Specific Diagram Options: Sequence diagrams have options for 'Show Sequence Numbers' or 'Right Angle Lines', while ER diagrams allow you to set minimum entity dimensions.

Remember that changes made in 'Diagram Style' will apply to all subsequent diagrams generated. If you want to apply a new style to an existing diagram, simply regenerate it.

4. Harness AI-Powered Error Recovery and Explanation

Even with the best settings, Mermaid diagrams can sometimes encounter syntax errors, especially when dealing with highly complex code. ArchToCode's robust error recovery system turns these challenges into learning opportunities.

  • Automatic Fixes: ArchToCode attempts client-side fixes for common issues like unclosed brackets or HTML tags before even showing an error.

  • Diagram Error Panel: If an error persists, a detailed panel appears with four tabs: 'Error Details', 'Suggestions', 'Regenerate Parameters', and 'Mermaid Code'.

  • AI-Powered Suggestions: The 'Suggestions' tab provides AI-analyzed recommendations tailored to your specific error, such as simplifying node labels or reducing complexity.

  • Explain Error: Click this button to get a comprehensive, AI-generated explanation of what went wrong, why it happened, and suggested fixes in plain English. This is incredibly helpful for understanding obscure Mermaid syntax issues.

  • Regenerate with Changes: Use the 'Regenerate Parameters' tab to adjust complexity, max nodes, or even add custom instructions to guide the AI toward a valid diagram.

This intelligent error handling not only helps you fix issues but also educates you on Mermaid best practices, allowing you to create more robust custom prompts in the future.

5. Use Custom Context File Selection for Focused Diagrams

Sometimes, the AI might include irrelevant files in its analysis, leading to a diagram that's too broad. ArchToCode's 'Custom Context File Selection' feature allows you to precisely control which files the AI considers.

  • Inclusive Mode: Add specific files to the AI's smart selection, ensuring they are prioritized while still allowing the AI to find other relevant dependencies.

  • Exclusive Mode: For highly focused diagrams, choose 'Use only these files'. This tells the AI to ignore all other files in the repository, providing a clean, targeted visualization of a specific component or module.

This feature is invaluable when you're trying to visualize a small part of a large codebase or when you want to create multiple diagrams, each focusing on a different aspect of your project.

Conclusion

Auto-generated Mermaid diagrams are a powerful tool for understanding and documenting code. By mastering ArchToCode's extensive customization capabilities, you can transform these diagrams from simple visualizations into highly effective, tailored insights. From influencing the AI's generation parameters and refining visual aesthetics to leveraging intelligent error recovery, you have unprecedented control over your code's visual representation.

Whether you're an architect planning a new system, a developer onboarding to a legacy codebase, or a team lead documenting project flows, ArchToCode provides the tools to make your diagrams clear, concise, and compelling. Don't just generate diagrams; master them.

Ready to take control of your code visualizations? Try ArchToCode today and start customizing your Mermaid diagrams like a pro! For more tips and tutorials, check out the ArchToCode YouTube channel.

Related posts