How to Filter Exercises Based on Their Target Muscle Group
You can filter exercises based on their target muscle group using the muscle_group field in 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, 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.
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.
// 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 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 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:
- Add a new filter section to the HTML after the Target Muscle chips:
<!-- Muscle Group filter -->
<div class="filter-section">
<div class="filter-summary">Muscle Group</div>
<div class="filter-options" id="muscle-group-chips"></div>
</div>
- Update the
buildFilterOptions()function to populate the new chips:
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
}
- Extend the filter state to include the new muscle group set:
filters: {
category: new Set(),
equipment: new Set(),
target: new Set(),
muscle_group: new Set() // <-- new set
},
- Update
applyFilters()(around line 1296) to respect the new set:
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_groupfield ofdata/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.htmluses astate.filtersobject with Sets; extending it requires adding a new Set formuscle_groupand updatingapplyFilters()to test against it. - The dataset contains 1,324 exercises with complete
muscle_groupandtargetmetadata.
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 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 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 with SQL table definitions if you prefer to import the data into a relational database.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →