Try it
Tap a muscle, use Tab and Enter, or search by name. Matching regions across front and rear highlight together.
Add it to your app
Copy the files you need from the muscle-map/ folder, or load the controller from a CDN. No build step, no package to install.
1. Get the files
Download the repo, or copy muscle-map/ into your project. It holds the SVGs, the controller and the JSON data.
git clone https://github.com/PerspicaciousGuy/Open-Muscle-Map.git
2. Or use the CDN
Web only. The SVGs still need to be fetched from your own server.
<script src="https://cdn.jsdelivr.net/gh/PerspicaciousGuy/Open-Muscle-Map@v1.1.0/muscle-map/muscle-map.js"></script> <!-- Pinned to a release tag. @main always serves the latest commit and can change under you. -->
Using an AI coding agent? Jump to For AI agents.
Inline the SVG, then bind the controller. Use inline markup: an <img> shows the picture but exposes no paths to tap. Tested in a headless browser.
<div id="body-map"></div>
<script src="./muscle-map/muscle-map.js"></script>
<script>
(async () => {
// Serve the files over HTTP; fetch() does not work from file://
const res = await fetch('./muscle-map/male-muscle-map.svg');
if (!res.ok) throw new Error('Could not load the muscle map');
document.querySelector('#body-map').innerHTML = await res.text();
const map = MuscleMap.createMuscleMap(document.querySelector('#body-map svg'), {
multiple: true, // tap toggles; keep several selected
bilateral: false, // true: left and right select together
onSelect: region => console.log(region.muscleId, region.side, region.view),
onChange: selected => console.log(selected)
});
map.setSelected(['right:lateral_deltoid']);
// map.setView('front'); map.clear(); map.destroy();
})();
</script>The controller is plain DOM code, so wrap it in an effect and destroy it on unmount.Not run in a React app yet
import { useEffect, useRef } from 'react';
import './muscle-map/muscle-map.js'; // classic script: sets window.MuscleMap, has no ES exports
import maleSvg from './muscle-map/male-muscle-map.svg?raw'; // Vite; use your bundler's raw-text import
export default function BodyMap({ onSelect }) {
const host = useRef(null);
useEffect(() => {
host.current.innerHTML = maleSvg;
const map = window.MuscleMap.createMuscleMap(host.current.querySelector('svg'), {
multiple: true,
onSelect: region => onSelect?.(region) // region.muscleId, region.side, region.selected
});
return () => map.destroy(); // required before the SVG is rebound
}, []);
return <div ref={host} />;
}A native component built on react-native-svg, with real per-region onPress. No WebView.Not run on a device yet
// npx expo install react-native-svg
// Copy MuscleMap.tsx, muscle-map.d.ts and both *-map-data.json files into one folder.
import React, { useState } from 'react';
import MuscleMap from './muscle-map/MuscleMap';
export default function BodySelector() {
const [selected, setSelected] = useState<string[]>([]);
return (
<MuscleMap
sex="male" // or "female"
view="both" // "front" | "rear" | "both"
width={360}
multiple
selectedKeys={selected} // e.g. ['right:lateral_deltoid']
onChange={setSelected}
activeColor="#FF6B35"
onMusclePress={region => {
// Filter your exercise catalog by region.muscleId
console.log(region.muscleId, region.side, region.view);
}}
/>
);
}Load male-webview.html in a WKWebView. Taps arrive through the muscleMap message handler.Not compiled yet
import SwiftUI
import WebKit
/// Loads male-webview.html (or female-webview.html) from the app bundle.
/// Add the file to the target as a bundle resource.
struct MuscleMapView: UIViewRepresentable {
var onSelect: (_ muscleId: String, _ selected: Bool) -> Void
func makeCoordinator() -> Coordinator { Coordinator(onSelect: onSelect) }
func makeUIView(context: Context) -> WKWebView {
let config = WKWebViewConfiguration()
config.userContentController.add(context.coordinator, name: "muscleMap")
let web = WKWebView(frame: .zero, configuration: config)
web.isOpaque = false
web.backgroundColor = .clear
if let url = Bundle.main.url(forResource: "male-webview", withExtension: "html") {
web.loadFileURL(url, allowingReadAccessTo: url.deletingLastPathComponent())
}
return web
}
func updateUIView(_ web: WKWebView, context: Context) {}
final class Coordinator: NSObject, WKScriptMessageHandler {
let onSelect: (String, Bool) -> Void
init(onSelect: @escaping (String, Bool) -> Void) { self.onSelect = onSelect }
func userContentController(_ controller: WKUserContentController,
didReceive message: WKScriptMessage) {
guard let body = message.body as? [String: Any],
body["type"] as? String == "musclemap:select",
let payload = body["payload"] as? [String: Any],
let id = payload["muscleId"] as? String else { return }
onSelect(id, payload["selected"] as? Bool ?? true)
}
}
}
// Drive the map from Swift:
// webView.evaluateJavaScript("window.muscleMap.setSelected(['right:lateral_deltoid'])")
// webView.evaluateJavaScript("window.muscleMap.clear()")Load the same WebView page from assets. The controller posts through window.ReactNativeWebView when it exists, so this points it at a Kotlin object.Not run on a device yet
// Put male-webview.html in app/src/main/assets/. Call setUpMuscleMap from your Activity or Fragment.
import android.webkit.JavascriptInterface
import android.webkit.WebView
import android.webkit.WebViewClient
class MuscleBridge(private val onSelect: (String) -> Unit) {
@JavascriptInterface
fun postMessage(json: String) = onSelect(json) // {"type":"musclemap:select","payload":{...}}
}
fun setUpMuscleMap(webView: WebView, onSelect: (String) -> Unit) {
webView.settings.javaScriptEnabled = true
webView.addJavascriptInterface(MuscleBridge(onSelect), "AndroidMuscleMap")
webView.webViewClient = object : WebViewClient() {
override fun onPageFinished(view: WebView, url: String) {
// The controller posts through window.ReactNativeWebView when it exists; point that at Android.
view.evaluateJavascript(
"window.ReactNativeWebView = { postMessage: m => AndroidMuscleMap.postMessage(m) };", null)
}
}
webView.loadUrl("file:///android_asset/male-webview.html")
}
// Drive the map from Kotlin:
// webView.evaluateJavascript("window.muscleMap.setSelected(['right:lateral_deltoid'])", null)
// webView.evaluateJavascript("window.muscleMap.clear()", null)For AI agents
A direct brief for Claude Code, Codex, Cursor and other coding agents: the rules they must not get wrong, the files to copy per platform, how to implement, and the checks that prove it works. Paste this into your agent, or give it the URL.
Read https://perspicaciousguy.github.io/Open-Muscle-Map/AGENTS.md and follow it to add the Open-Muscle-Map muscle map to this project. Run the verification steps and report what you could not test.
Read the full AGENTS.md
# Integrating Open-Muscle-Map (instructions for AI coding agents)
You are adding a tappable muscle map to someone's app. Follow this file literally. Everything you need is in `muscle-map/`. Do not redraw, flip, re-color paths in the SVG, or invent muscle names.
## 1. Facts you must not get wrong
- **Join key:** `muscleId` (for example `lateral_deltoid`). It is identical on male and female, front and rear. Map it to the app's own data. The full list is `muscle-map/muscles.json`; 32 are selectable (`selectable: true`), 5 are joints, fascia or tendons and are not.
- **Selection key:** `side:muscleId` (`right:lateral_deltoid`). In bilateral mode it is `both:muscleId`.
- **Sides are the person's, not the screen's.** Anatomical right is screen-left in the front view and screen-right in the rear view. The `side` field already accounts for this. Never mirror an SVG or swap sides.
- **One muscle is many panels.** Several drawn tiles share one `muscleId` (abs, triceps, glutes). Count muscles by `muscleId`, never by tile.
- **Inline the SVG.** An `<img>` or native image loses the per-region paths. Web and WebView use the controller; React Native uses `MuscleMap.tsx`; do not parse the SVG by hand.
- **The map is schematic.** Do not present it as medically exact. Forearm flexors and extensors, hip adductors, medial hamstrings, fibularis, posterior rotator cuff and erector spinae are groups on purpose.
## 2. Pick the path
| Target | Use | Copy these files |
|---|---|---|
| Web, any framework | `muscle-map.js` controller + inline SVG | `muscle-map.js`, `male-muscle-map.svg`, `female-muscle-map.svg` |
| React (web) | same controller inside an effect, `destroy()` on unmount | same as web |
| React Native / Expo | native component, no WebView | `MuscleMap.tsx`, `muscle-map.d.ts`, `male-map-data.json`, `female-map-data.json`; install `react-native-svg` |
| SwiftUI / WKWebView | WebView page + `muscleMap` message handler | `male-webview.html`, `female-webview.html` |
| Android WebView | WebView page + JS interface shim | `male-webview.html`, `female-webview.html` |
Code for each path is in `site/code/` (and on the live site under Guides). Start from it; adapt names and wiring to the host app.
## 3. Implement
1. Read the host app's conventions first (framework, state, styling, how assets are bundled). Match them.
2. Copy only the files for your path into the app's own folder. Keep `muscle-map/` files unmodified so they can be updated later.
3. Wire the callback: on select you receive `{ muscleId, muscleName, side, view, selected, selectionKey, ... }`. Translate `muscleId` into the app's own concept (exercise filter, heatmap key). Put that mapping in one table in the app, with an explicit entry for every selectable `muscleId` you support and a visible fallback for the rest.
4. Selected color: set the CSS variable `--muscle-active` (web) or `activeColor` (React Native). Hover and focus: `--muscle-hover`, `--muscle-focus`. Do not edit the SVG fills.
5. Heatmap: `controller.setColors({ muscleId: 0..1 | 'css colour' })` (web, WebView) or the `colors` prop (React Native, any colour string). Unknown `muscleId`s and non-finite numbers throw. Selection colour wins over heat. `clearColors()` removes them.
6. Single vs several selections: `multiple`. Left and right together: `bilateral`.
## 4. Verify (do all of it, report what you could not run)
Run these from the repo root of this project before touching the host app:
```bash
node scripts/verify-data.mjs # SVG, JSON data, regions.json and muscles.json agree (no dependencies)
node scripts/build-site.mjs # builds _site/ (the demo, guides and ID table)
```
Browser checks (needs `npm install --no-save playwright && npx playwright install chromium`):
```bash
node scripts/verify-browser.mjs # selection modes, keyboard, guide snippet, phone layout, no console errors
node scripts/verify-react.mjs # React guide built with Vite and tapped (needs network for npm install)
```
Then verify the integration in the host app:
- **Web / React:** `muscle-map.js` is a classic script with no ES exports: import it for its side effect and use `window.MuscleMap` (a default import fails under the Vite dev server). Open the page over HTTP (`fetch()` fails from `file://`). Tap a muscle: the `onSelect` payload has the expected `muscleId` and `side`. Tap a front-view and a rear-view panel of the same muscle: both highlight. Press Tab to a region, then Enter: it selects. Press Escape: it clears. Check the browser console is clean.
- **React Native:** `npx tsc --noEmit` passes (enable `resolveJsonModule`). Run on a simulator, tap, and log `region.muscleId`.
- **SwiftUI:** the snippet must compile for an iOS target (CI runs `xcrun --sdk iphonesimulator swiftc -typecheck`). Run in the simulator: the `muscleMap` handler receives `type == "musclemap:select"`. Confirm `male-webview.html` is in the app bundle's resources, or nothing loads.
- **Android:** the page must be loaded from assets; confirm `evaluateJavascript` that defines `window.ReactNativeWebView` runs after page load, then tap and check the Kotlin callback.
## 5. What has and has not been tested (do not claim more)
| Path | Status |
|---|---|
| Data consistency, controller, JavaScript guide, demo site | Tested in headless Chromium by `scripts/verify-*.mjs` (CI: `.github/workflows/verify.yml`) |
| `MuscleMap.tsx` and the React Native guide | Type-checked in CI; not run on a device |
| React guide | Built with Vite and run under both the production build and the dev server in headless Chromium by `scripts/verify-react.mjs` (CI: `verify.yml`); not run in other bundlers or frameworks |
| SwiftUI guide | Compiled by `.github/workflows/verify-swift.yml` once it has run; not run in a simulator |
| Android guide | Compiled against the Android SDK by `verify.yml` once it has run; not run on a device |
If you run a path that is listed as not run, say so in your report with the result, and fix `site/code/` if the snippet was wrong.
## 6. Common mistakes
- Expecting a white backdrop: the artwork is transparent. Give it a neutral surface, or set `[data-background] { fill: ... }` / React Native `backgroundColor`.
- Loading the SVG as `<img>`: nothing is tappable.
- Creating the controller twice on the same SVG: call `destroy()` before rebinding (React effects in strict mode do this).
- Counting `data-region-id` elements as muscles: there are 102 selectable panels but 32 muscles.
- Treating `selectable: false` entries (knee, back of knee, iliotibial band, Achilles) as muscles.
- Hard-coding hex colors in the SVG instead of the CSS variables.
- Using `@main` in a CDN URL in production: pin a tag or commit.API
One function, MuscleMap.createMuscleMap(svg, options), returns a controller. Create it once per inline SVG.
multipleTap toggles a muscle and keeps the others. Default is one selection.
bilateralLeft and right select together. Keys become both:muscle_id.
onSelect(region)Fires per tap with muscleId, side, view, selected and the full region metadata.
onChange(selected)The logical selection, one entry per muscle, not per drawn tile.
setSelected(keys)Select from code, for example ['right:lateral_deltoid'].
setView('both' | 'front' | 'rear')Switch the visible side.
setColors(values)Heatmap. { lateral_deltoid: 0.8, biceps_brachii: '#2dd4bf' }: a number from 0 to 1 is blended from blue to red (override with { low, high }), a string is used as a CSS colour. Selected muscles keep the selection colour. clearColors() removes them.
clear() destroy()Clear the selection, or remove the listeners before rebinding.
--muscle-activeCSS variable for the selected fill. --muscle-hover and --muscle-focus cover the other states.
Anatomical right is screen-left in the front view and screen-right in the rear view. The side metadata already accounts for this, so do not flip the SVGs horizontally. TypeScript types are in muscle-map.d.ts.
Muscle IDs
Use muscleId to connect a tap to your own data, for example an exercise catalog. The IDs are the same on both bodies and both views.
| Name | ID | Group | Type | Selectable |
|---|---|---|---|---|
| Sternocleidomastoid | sternocleidomastoid | neck | muscle | Yes |
| Trapezius | trapezius | upper_back | muscle | Yes |
| Anterior deltoid | anterior_deltoid | shoulders | muscle | Yes |
| Lateral deltoid | lateral_deltoid | shoulders | muscle | Yes |
| Posterior deltoid | posterior_deltoid | shoulders | muscle | Yes |
| Pectoralis major (chest) | pectoralis_major | chest | muscle | Yes |
| Biceps brachii | biceps_brachii | upper_arms | muscle | Yes |
| Brachialis | brachialis | upper_arms | muscle | Yes |
| Serratus anterior | serratus_anterior | core | muscle | Yes |
| Rectus abdominis (abs) | rectus_abdominis | core | muscle | Yes |
| External oblique | external_oblique | core | muscle | Yes |
| Forearm flexors | forearm_flexors | forearms | muscle group | Yes |
| Tensor fasciae latae | tensor_fasciae_latae | hips | muscle | Yes |
| Iliopsoas (hip flexors) | iliopsoas | hips | muscle | Yes |
| Hip adductors (inner thigh) | hip_adductors | adductors | muscle group | Yes |
| Sartorius | sartorius | hips | muscle | Yes |
| Rectus femoris | rectus_femoris | quadriceps | muscle | Yes |
| Vastus lateralis | vastus_lateralis | quadriceps | muscle | Yes |
| Vastus medialis | vastus_medialis | quadriceps | muscle | Yes |
| Patella / front knee | patella_region | joints | joint | No |
| Tibialis anterior | tibialis_anterior | shins | muscle | Yes |
| Gastrocnemius | gastrocnemius | calves | muscle | Yes |
| Fibularis (peroneal) group | fibularis_group | shins | muscle group | Yes |
| Soleus | soleus | calves | muscle | Yes |
| Posterior rotator cuff | posterior_rotator_cuff | upper_back | muscle group | Yes |
| Triceps brachii | triceps_brachii | upper_arms | muscle | Yes |
| Latissimus dorsi (lats) | latissimus_dorsi | upper_back | muscle | Yes |
| Erector spinae / lower back | erector_spinae | lower_back | muscle group | Yes |
| Forearm extensors | forearm_extensors | forearms | muscle group | Yes |
| Gluteus medius | gluteus_medius | glutes | muscle | Yes |
| Gluteus maximus | gluteus_maximus | glutes | muscle | Yes |
| Iliotibial band region | iliotibial_tract | connective_tissue | fascia | No |
| Biceps femoris | biceps_femoris | hamstrings | muscle | Yes |
| Medial hamstrings | medial_hamstrings | hamstrings | muscle group | Yes |
| Back of knee (popliteal region) | popliteal_region | joints | joint | No |
| Achilles tendon region | achilles_tendon | connective_tissue | tendon | No |
| Patellar tendon / upper shin region | patellar_tendon_region | connective_tissue | tendon | No |
Boundaries are simplified for a fitness diagram, not a dissection atlas. Forearm flexors and extensors, hip adductors, medial hamstrings, fibularis muscles and the lumbar erectors are groups because the artwork cannot separate the individual muscles. Knee, tendon and fascia panels are drawn but not selectable. See the verification notes for what is source-backed and what is not.