N
NJHTools

Git Graph Diagram Maker

Write commits, branches and merges as Mermaid gitGraph commands and get a branching diagram that explains your git workflow, with live preview and SVG or PNG export. Free, no signup, and it runs in your browser.

Zoom
100%
Export
Mermaid code15 lines

Tab inserts spaces. Press Esc, then Tab, to move focus out. Autosaved in this browser.

PreviewLoading Mermaid…

Rendering…

Example git graph code

This is the Mermaid source loaded in the editor above. Copy it into a Markdown file inside a ```mermaid block and GitHub, GitLab, Notion or Obsidian will render it.

gitGraph
    commit id: "init"
    commit id: "add readme"
    branch develop
    checkout develop
    commit id: "setup ci"
    branch feature/login
    checkout feature/login
    commit id: "login form"
    commit id: "auth api"
    checkout develop
    merge feature/login
    checkout main
    merge develop tag: "v1.0.0"
    commit id: "hotfix" type: HIGHLIGHT

Git graph syntax cheat sheet

SyntaxWhat it does
gitGraphStart a Git graph. History begins on the main branch.
commit id: "msg"Add a commit. Options: tag: "v1", type: NORMAL | REVERSE | HIGHLIGHT.
branch nameCreate a branch from the current one and switch to it.
checkout nameSwitch to an existing branch (switch also works).
merge nameMerge the named branch into the current one (can take a tag).
cherry-pick id: "x"Copy a commit from another branch onto the current one.

How to make a Mermaid git graph

  1. 1Start the code with gitGraph.
  2. 2Add commits on the main branch with commit.
  3. 3Create a branch with branch develop and switch with checkout develop.
  4. 4Merge back with checkout main then merge develop.
  5. 5Export as SVG or PNG, or copy a share link.

Commands mirror git

The diagram is a script of git-like commands run from top to bottom: commit adds a commit to the current branch, branch name creates and switches to a new branch, checkout name switches, and merge name merges that branch into the current one.

The graph starts on a branch called main. A branch must exist before you can check it out or merge it.

Commit IDs, tags and types

Give a commit a readable label with commit id: "Add login", and mark releases with commit tag: "v1.0". Merges accept a tag too.

commit type: HIGHLIGHT emphasises a commit and type: REVERSE marks a revert. cherry-pick id: "Add login" copies an existing commit, by its id, onto the current branch.

Diagramming a branching strategy

Git graphs are ideal for documenting GitFlow, trunk-based development or a release process in a README or onboarding guide.

Show only the commits that explain the strategy; a handful per branch is usually enough.

Frequently Asked Questions

How do I draw a git branch diagram in Mermaid?↓

Start with gitGraph, then write commit, branch feature, commit, checkout main and merge feature, one per line. The diagram follows the commands in order.

How do I add a version tag to a commit?↓

Use commit tag: "v1.0". You can combine it with an id, as in commit id: "Release" tag: "v1.0".

Why does my merge fail to render?↓

The branch must exist and you must be checked out on the target branch. Merging a branch into itself is also an error.

Will this diagram render on GitHub, GitLab or Notion?↓

Yes, all three render Mermaid. On GitHub and GitLab, put the code in a fenced code block that starts with ```mermaid. In Notion, add a code block and set its language to Mermaid. Hosted platforms may run an older Mermaid version, so very new syntax can fail there.

How do I export the diagram as PNG or SVG?↓

Use the export buttons above the preview. SVG stays sharp at any size and suits docs and slides; PNG is a raster image that works anywhere images are accepted. Both are created in your browser.

How does sharing work, and is my diagram private?↓

The share link stores your diagram code in the URL hash, the part after #, which browsers do not send to servers. Nothing is uploaded, and your work is autosaved in your own browser. Anyone with the link can see the diagram, so share it only with people you trust.

Last updated: