# How to Filter Exercises Based on Their Target Muscle Group

> Easily filter exercises by target muscle group using the muscle_group field in the exercises dataset. Discover detailed anatomical targeting for 1,324 exercises.

- Repository: [Hasan Emir Yıldırım/exercises-dataset](https://github.com/hasaneyldrm/exercises-dataset)
- Tags: how-to-guide
- Published: 2026-07-17

---

**You can filter exercises based on their target muscle group using the `muscle_group` field in [`data/exercises.json`](https://github.com/hasaneyldrm/exercises-dataset/blob/main/data/exercises.json), which contains 1,324 exercise records with detailed anatomical targeting data.**

The hasaneyldrm/exercises-dataset repository provides a comprehensive JSON database of exercises with detailed metadata. Each exercise record includes a `muscle_group` field that identifies the primary synergist muscles, allowing you to programmatically filter exercises based on their target muscle group using Python, JavaScript, or the built-in web explorer.

## Understanding the Dataset Schema

The exercise data resides in [`data/exercises.json`](https://github.com/hasaneyldrm/exercises-dataset/blob/main/data/exercises.json), where each entry contains anatomical targeting fields. The `muscle_group` property identifies the primary synergist muscles (e.g., "biceps", "glutes"), while the `target` field specifies the main muscle the movement works. This structure enables precise filtering by physiological criteria.

## Filtering by Muscle Group in Python

To filter the dataset using Python, load the JSON file and test the `muscle_group` property against your desired value.

```python
import json

# Load the dataset

with open("data/exercises.json", "r", encoding="utf-8") as f:
    exercises = json.load(f)

# Choose the muscle group you want

desired_group = "biceps"          # any value from the `muscle_group` field

# Simple filter

by_muscle = [ex for ex in exercises if ex["muscle_group"] == desired_group]

print(f"{len(by_muscle)} exercises target the {desired_group} muscle group")
for ex in by_muscle[:5]:          # show a few examples

    print("- ", ex["name"], f"({ex['target']})")

```

This approach leverages the standard JSON schema defined in the repository's data file.

## Filtering by Muscle Group in JavaScript

For Node.js applications, require the JSON file and use the array `filter` method to isolate exercises by their `muscle_group` value.

```javascript
// Load the JSON file (Node.js)
const exercises = require("./data/exercises.json");

// Filter for a given muscle group
const group = "glutes";
const gluteExercises = exercises.filter(
  (ex) => ex.muscle_group === group
);

console.log(`${gluteExercises.length} exercises for ${group}`);
gluteExercises.slice(0, 5).forEach((ex) => {
  console.log(`- ${ex.name} (target: ${ex.target})`);
});

```

The browser application in [`index.html`](https://github.com/hasaneyldrm/exercises-dataset/blob/main/index.html) uses the same dataset structure, storing exercises in the `EXERCISES` constant.

## Extending the Web UI to Filter by Muscle Group

The client-side explorer in [`index.html`](https://github.com/hasaneyldrm/exercises-dataset/blob/main/index.html) implements filtering through chip groups for **Category**, **Equipment**, and **Target Muscle**. The filter logic at line 1300 builds a `state.filters` object and tests each exercise against those sets. To add muscle group filtering, follow these steps:

1. **Add a new filter section** to the HTML after the Target Muscle chips:

```html
<!-- Muscle Group filter -->
<div class="filter-section">
  <div class="filter-summary">Muscle Group</div>
  <div class="filter-options" id="muscle-group-chips"></div>
</div>

```

2. **Update the `buildFilterOptions()` function** to populate the new chips:

```javascript
function buildFilterOptions() {
  const cats   = uniqueSorted(state.exercises.map(e => e.category));
  const equips = uniqueSorted(state.exercises.map(e => e.equipment));
  const targets = uniqueSorted(state.exercises.map(e => e.target));
  const groups = uniqueSorted(state.exercises.map(e => e.muscle_group));

  renderChips('category-chips',   cats,   'category');
  renderChips('equipment-chips', equips, 'equipment');
  renderChips('target-chips',    targets,'target');
  renderChips('muscle-group-chips', groups, 'muscle_group');   // <-- new line
}

```

3. **Extend the filter state** to include the new muscle group set:

```javascript
filters: {
  category: new Set(),
  equipment: new Set(),
  target: new Set(),
  muscle_group: new Set()    // <-- new set
},

```

4. **Update `applyFilters()`** (around line 1296) to respect the new set:

```javascript
if (muscle_group.size && !muscle_group.has(ex.muscle_group)) return false;

```

The generic badge removal handler already works for any key present in `state.filters`, so no additional event handling is required.

## Summary

- The **Exercises Dataset** stores muscle group data in the `muscle_group` field of [`data/exercises.json`](https://github.com/hasaneyldrm/exercises-dataset/blob/main/data/exercises.json).
- **Python** filtering uses list comprehensions to check `ex["muscle_group"]` against desired values.
- **JavaScript** filtering uses the `filter()` array method with the same property check.
- The **web UI** in [`index.html`](https://github.com/hasaneyldrm/exercises-dataset/blob/main/index.html) uses a `state.filters` object with Sets; extending it requires adding a new Set for `muscle_group` and updating `applyFilters()` to test against it.
- The dataset contains **1,324 exercises** with complete `muscle_group` and `target` metadata.

## Frequently Asked Questions

### What is the difference between the `muscle_group` and `target` fields?

The `muscle_group` field identifies the primary synergist muscles involved in the exercise, while the `target` field specifies the main muscle that the movement works. For example, a bicep curl might list "biceps" as the muscle group and "brachialis" as the specific target.

### Can I filter by multiple muscle groups simultaneously?

Yes. The web UI implementation uses Sets (`state.filters.muscle_group`) to store selected values, allowing multiple selections. In Python or JavaScript, you can modify the filter logic to check for inclusion in an array of desired groups rather than testing for equality.

### Where is the filter logic implemented in the source code?

The client-side filter logic is implemented in [`index.html`](https://github.com/hasaneyldrm/exercises-dataset/blob/main/index.html) around line 1300, specifically in the `applyFilters()` function. This function tests each exercise against the `state.filters` sets for category, equipment, target, and (after extension) muscle group.

### How do I access the raw exercise data without the web interface?

The raw data is available in [`data/exercises.json`](https://github.com/hasaneyldrm/exercises-dataset/blob/main/data/exercises.json) as a flat JSON array. You can load this file directly in Python, Node.js, or any language that parses JSON. The repository also includes [`setup.html`](https://github.com/hasaneyldrm/exercises-dataset/blob/main/setup.html) with SQL table definitions if you prefer to import the data into a relational database.