Skip to main content
Mermaid supports icons from the Iconify library, giving you access to thousands of icons from popular icon sets. You can register icon packs and use them in your diagrams.

Overview

Mermaid uses Iconify’s icon format and allows you to:
  • Register icon packs from the Iconify ecosystem
  • Load icons from CDN or bundled packages
  • Use custom names for icon packs (overriding the default prefix)
  • Lazy load icon packs only when used in diagrams

Registering icon packs

Icon packs must be registered before they can be used in diagrams. The registerIconPacks() method accepts an array of icon pack configurations.

Using CDN

Load icon packs directly from a CDN:

Using packages with lazy loading

Install an icon pack as a dependency and lazy load it:
Lazy loading is recommended for better performance. Icons are only loaded when a diagram uses them.

Using packages without lazy loading

Load icon packs immediately when the application starts:

Icon pack configuration

Each icon pack configuration supports the following properties:

Custom names vs. default prefix

You can use a custom name to simplify icon references:

Using icons in diagrams

Once registered, icons can be used in diagrams using the syntax packName:iconName.

Flowchart example

Architecture diagram example

Available icon packs

Iconify provides access to over 150 icon sets. Popular options include:

Brand icons

  • @iconify-json/logos - Brand and technology logos
  • @iconify-json/simple-icons - Simple icons for popular brands
  • @iconify-json/devicon - Programming languages and development tools

General purpose

  • @iconify-json/fa6-solid - Font Awesome 6 Solid
  • @iconify-json/fa6-regular - Font Awesome 6 Regular
  • @iconify-json/mdi - Material Design Icons
  • @iconify-json/heroicons - Heroicons

Specialized

  • @iconify-json/emojione - Emoji One
  • @iconify-json/twemoji - Twitter Emoji
  • @iconify-json/noto - Google Noto Emoji
Browse all available icon packs at icones.js.org.

Best practices

Performance optimization

  • Use lazy loading - Load icon packs only when needed
  • Register specific packs - Don’t register icon packs you won’t use
  • Bundle icons in production - For better performance, bundle frequently used icons

Naming conventions

  • Use short custom names - Make icon references easier to type
  • Be consistent - Use the same naming pattern across your application
  • Document your icons - Keep a list of registered icon packs

Error handling

Complete example

Here’s a complete example with multiple icon packs:

Troubleshooting

Icons not displaying

  1. Check pack registration - Ensure the icon pack is registered before rendering diagrams
  2. Verify icon name - Check that the icon exists in the pack at icones.js.org
  3. Check syntax - Use packName:iconName format
  4. Inspect console - Look for loading errors in browser console

Performance issues

  • Use lazy loading - Don’t load all icons upfront
  • Minimize pack size - Only register packs you actually use
  • Cache CDN responses - Configure proper cache headers

Next steps

Layouts

Configure layout engines for your diagrams

Math support

Add mathematical expressions to diagrams