# Configure Karabiner on macOS with Kotlin

DevFeed: [Configure Karabiner on macOS with Kotlin](<https://devfeed.tech/articles/configure-karabiner-with-ease-kotlin-25274.md>)

Original publisher: [Read original article](<https://kau.sh/blog/karabiner-kt/>)

Author: Kaushik Gopal

Published: 2025-05-17T20:23:40Z

Content type: tutorial

Language: en

Sources: [Kaushik Gopal's Site](<https://devfeed.tech/sources/kaushik-gopal-s-site.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [macOS](<https://devfeed.tech/topics/macos.md>), [configuration](<https://devfeed.tech/topics/configuration.md>), [JSON](<https://devfeed.tech/topics/json.md>), [TypeScript](<https://devfeed.tech/topics/typescript.md>)

Tags: [configuration](<https://devfeed.tech/tags/configuration.md>), [dsl](<https://devfeed.tech/tags/dsl.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [json](<https://devfeed.tech/tags/json.md>), [keyboard](<https://devfeed.tech/tags/keyboard.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [macos](<https://devfeed.tech/tags/macos.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [productivity](<https://devfeed.tech/tags/productivity.md>), [re](<https://devfeed.tech/tags/re.md>), [repo](<https://devfeed.tech/tags/repo.md>)

## AI overview

This tutorial introduces karabiner-kt, a Kotlin-based DSL for managing Karabiner keyboard configurations on macOS. It addresses the difficulty of maintaining large karabiner.json files and shows how Kotlin rules can generate the JSON consumed by Karabiner.

## Source excerpt

If you're obsessed with productivity hacks, you've probably heard of Karabiner - the ultimate tool for keyboard customization on macOS. But maintaining Karabiner's config is a pain. In this post I'll show you a simpler, Kotlin-powered way to wrangle your Karabiner setup, so you don't have to wrestle with massive, unwieldy JSON. On Karabiner ## Here's the gist: Karabiner lets you intercept any keystroke and remap it to... well, pretty much anything. Want to turn Caps Lock into a Hyper key? Make your keyboard launch confetti? It's all possible. Take the classic usecase: remap Caps Lock to Hyper (⌘⌥⌃⇧) when held, Escape when tapped. That's easy to do but just scratches the surface. With Karabiner, you can build many more customizations that supercharge your workflow. Maintaining that karabiner.json ## I was watching a video by Max Stoiber where he uses Raycast1 & Karabiner. But what struck me was how he customized and maintained his karabiner setup. Karabiner runs off a single .json config file. But that .json configuration can become unwieldy and difficult to manage, as your rules grow in complexity. For example: I require a ~2700 line .json for all my hacks. It's impossible to maintain it as pure json. Max uses TypeScript to maintain his rules -which then compiles down to a .json file- that Karabiner can consume. I really like this approach. If you read my previous blog post, I also ran into a very similar problem and used goku, which in turn used the very esoteric and terse edn format. I like TypeScript over edn but you know what I'd like even better? Kotlin! So on a ✈ ride back home, I decided to whip up karabiner-kt. I'm really happy with my solution. Kotlin affords a much more pleasant DSL than most other2 languages. Here's what a Karabiner rule looks like in Kotlin : karabinerRule { description = "Right Cmd -> Ctrl (Enter alone)" mapping { fromKey = RightCommand toKey = RightControl toKeyIfAlone = KeyCode.ReturnOrEnter forDevice { identifiers = DeviceIdentifier.A