Skip to main content

qmk-layout-fmt

Formatter for QMK keymap.c LAYOUT() blocks.

QMK is an open-source firmware for custom keyboards. Keymaps are defined in C files using LAYOUT() macros that map physical keys to actions across multiple layers.

This tool aligns columns within those layer definitions so that keys line up vertically across rows, making keymaps easier to read and review.

Works with any QMK LAYOUT macro — auto-detects shape from standard names (LAYOUT_split_3x6_3, LAYOUT_ortho_4x12, etc.) and supports custom macros via config file.

Installation

With uv:

uv tool install qmk-layout-fmt

With pipx:

pipx install qmk-layout-fmt

Or directly from the repository:

uv tool install git+https://github.com/OneDeadKey/qmk-layout-fmt

Development

git clone https://github.com/OneDeadKey/qmk-layout-fmt.git
cd qmk-layout-fmt
uv sync
uv run qmk-layout-fmt keymap.c

Maintainer tasks

Requires just:

just build          # build the package
just publish        # build + publish to PyPI
just bump 0.2.0     # update version everywhere
just run keymap.c   # run the formatter locally

Usage

# Format in place (default)
qmk-layout-fmt keymap.c

# Check formatting without modifying (exit code 1 if unformatted, useful for CI)
qmk-layout-fmt keymap.c --check

# All layers share the same column widths (default: each layer aligns independently)
qmk-layout-fmt keymap.c --uniform

Layout shape override

For standard QMK macros (LAYOUT_split_3x6_3, LAYOUT_ortho_4x12, LAYOUT_planck_grid, etc.), the shape is auto-detected from the macro name.

For custom macros, use CLI flags:

qmk-layout-fmt keymap.c --main-rows 4 --cols-per-side 6 --thumb-per-side 3

Or create a .qmk-layout-fmt.toml config file in your project (searched upward from the input file):

[layouts.MY_CUSTOM_LAYOUT]
main_rows = 4
cols_per_side = 6
thumb_per_side = 3

Supported layouts

Macro pattern Auto-detected Example
LAYOUT_split_{R}x{C}_{T} rows, cols per side, thumbs per side LAYOUT_split_3x6_3 → 3 rows of 6+6, thumb 3+3
LAYOUT_ortho_{R}x{C} rows, cols split in half LAYOUT_ortho_4x12 → 4 rows of 6+6
LAYOUT_planck_grid 4 rows of 6+6
Custom macros via .qmk-layout-fmt.toml or CLI flags ONEDEADKEY_LAYOUT

Metadata

Release files for qmk-layout-fmt 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qmk-layout-fmt 0.1.2
File Size Uploaded
qmk_layout_fmt-0.1.2.tar.gz 8.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for qmk-layout-fmt 0.1.2
File Interpreter ABI Platform
qmk_layout_fmt-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 18.2 kB

Release files / qmk_layout_fmt-0.1.2.tar.gz

Download URL qmk_layout_fmt-0.1.2.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4660fe5dad59de343bc6cedd45dd767531f43aef7e2ffd48f286b9e04403b29f
BLAKE2b-256 checksum
How to use checksums
6ad0aacdbb90e33b1fd3ffb12bb274881f0c9cbcabcd5040b9af9f374dc0af6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Manjaro Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / qmk_layout_fmt-0.1.2-py3-none-any.whl

Download URL qmk_layout_fmt-0.1.2-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e08f6de248f8027e64b91c888117fa643ff1af51cc22d0283c747e7ce4186113
BLAKE2b-256 checksum
How to use checksums
02e957e8058a61b76296832d249ca63231786799f5065ffc3d6f08c3f281dbc9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Manjaro Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page