Conventional Commits cheatsheet and message generator

Build a Conventional Commits message and look up the types, scopes, breaking changes, footers and examples.

loading Conventional Commits cheatsheet and message generator
About this tool

What is Conventional Commits?

Conventional Commits is a small convention for writing commit messages. Instead of free text, the first line has a fixed shape: a type, an optional scope, and a short description. A tool can read that shape, and so can a person scanning the history. From it you can generate a changelog, decide the next version number and filter the log for features or fixes. The convention is version 1.0.0 of a public specification, and it was designed to work with Semantic Versioning.

This page has two parts. At the top there is a message generator: pick the type, fill in the scope, the description, a body and footers, and the final message appears below, ready to copy. Below it there is a searchable cheatsheet with the format, the types, breaking changes, the rules and the tools around the convention (commitlint, husky, commitizen). Everything runs in your browser, with no account and nothing sent anywhere.

The shape of a message is:

<type>[optional scope]: <description>

[optional body]

[optional footer(s)]

How it connects to SemVer

Semantic Versioning numbers a release as MAJOR.MINOR.PATCH. Conventional Commits maps to it like this:

  • fix is a PATCH release, for example 1.4.2 to 1.4.3.
  • feat is a MINOR release, for example 1.4.2 to 1.5.0.
  • A breaking change is a MAJOR release, for example 1.4.2 to 2.0.0, whatever the type.

The specification itself requires only feat and fix. The other types in the generator (docs, style, refactor, perf, test, build, ci, chore, revert) come from the Angular convention and are the ones most teams use. Types other than those two do not change the version by themselves.

How to use the message generator

  1. Choose the Type in the list. Each option shows a short meaning, such as feat · a new feature or fix · a bug fix.
  2. Fill in the optional Scope with the part of the code that changed, such as api, parser or ui. It cannot contain spaces, parentheses, colons or an exclamation mark, and the page warns you if it does.
  3. Write the Description in the imperative, saying what the commit does. This is the only field that is always required. Without it the copy button stays disabled.
  4. Add a Body if the reason for the change needs more than one line. It goes after a blank line.
  5. Add Footers, one per line, such as Closes #123.
  6. Turn on Breaking change if the change breaks compatibility. The header gets a ! before the colon, and a field appears where you can write what breaks. That text becomes a BREAKING CHANGE: footer.
  7. Watch the counter next to the Message title. It shows the length of the first line against 72. Above 72, a hint suggests moving details to the body.
  8. Press Copy message and paste it into git commit, your editor or the pull request.

For the full list of Git commands around commits, see the Git cheatsheet.

Examples

A fix with a scope

Type fix, scope auth, description refresh the token before it expires:

fix(auth): refresh the token before it expires

The header has 46 characters. It is a PATCH release.

A feature with a body and a footer

feat(api): add pagination to the users endpoint

The endpoint returned every user at once and timed out on large
accounts. It now accepts page and per_page.

Closes #123

The blank lines are required. GitHub and GitLab close issue 123 when the commit reaches the default branch.

A breaking change

With the Breaking change toggle on and a note written, the generator produces:

feat(api)!: rename the field name to title

BREAKING CHANGE: the field name is now title in every response

Both marks are valid. The ! is visible in the log, and the footer explains what to do. Either one alone is enough to signal a MAJOR release.

Filter the history

git log --oneline --grep="^feat" --grep="^fix"

This lists the commits whose message starts with feat or fix. With several --grep options, Git shows the commits that match any of them.

Common mistakes

A vague description

fix: bug and chore: changes pass the format but say nothing. Describe the effect: fix: stop the crash when the list is empty.

A period, capitals and a very long first line

The convention is a lower-case imperative description without a final period. The 72-character limit is a habit, not part of the specification: the log and review tools cut longer lines. Put the details in the body.

Mixing several changes in one commit

A commit with feat and fix forces you to pick one type. If you need two types, you need two commits.

Writing the breaking change in lower case

The footer token must be BREAKING CHANGE in capital letters (BREAKING-CHANGE is also accepted). Lower case is not recognized by tools that read the convention. The ! before the colon avoids the problem.

A scope with spaces

feat(user api): ... is not valid. Use a single word, or hyphens: feat(user-api): ....

Using feat for something internal

If users see no difference, it is probably refactor, chore or build. A wrong feat triggers a MINOR release without a feature.

Frequently asked questions

Do I have to use a scope?

No. The scope is optional. It helps when the project has clear areas, such as packages or modules, and gets in the way when everything is one piece.

What is the difference between feat! and a BREAKING CHANGE footer?

Both mark a MAJOR change. The ! is a short mark in the header, and the footer lets you explain what breaks and what to do. You can use both, as the generator does when you write a note.

Does the convention require English?

No. The specification does not set a language, but the keywords (feat, fix, BREAKING CHANGE) stay as they are so tools can read them. The description can be in your team's language.

How do I check that my team follows it?

Use a linter such as commitlint with the @commitlint/config-conventional preset, run in CI or in a commit-msg hook with husky. The cheatsheet part of this page lists the commands. For a similar look at another convention, see the regular expressions cheatsheet.

Can I fix a message I already wrote?

For the last commit, git commit --amend -m "fix: correct message" rewrites it. If it was already pushed, rewriting changes the history for everyone, so agree on it with the team first.

Report a problem