How to Filter Exercises by Body Part Category in the Exercises Dataset

Filter the exercises array using the category field, which contains the primary body part label (e.g., "chest", "back", "upper legs", "shoulders") for each of the 1,324 records in the dataset.

The hasaneyldrm/exercises-dataset repository stores fitness data as a JSON array in data/exercises.json. To filter exercises by body part category, you query the category field, which identifies the primary muscle group targeted by each exercise. The dataset also provides a duplicate body_part field for backward compatibility, but category is the authoritative identifier.

Understanding the Body Part Category Fields

Each exercise object in data/exercises.json contains two fields that identify the target muscle group:

  • category – The primary body part label (e.g., "chest", "back", "upper legs", "shoulders")
  • body_part – A duplicate of category maintained for backward compatibility

According to the README’s data schema table, these fields are described in lines 78-82 of the documentation. The JSON schema in data/exercises.schema.json formally defines the category property, ensuring consistent classification across all 1,324 exercise records.

Filtering Exercises by Body Part Category

To obtain exercises for a specific body part, filter the array where category matches your target value. This operation is lightweight and suitable for client-side processing in any language that parses JSON.

Python Implementation

Use the standard json module to load the dataset and list comprehension to filter by category:

import json

# Load the full dataset

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

# Helper to filter by a list of body part categories

def filter_by_body_parts(parts):
    return [ex for ex in exercises if ex["category"] in parts]

# Example: chest, back, legs, shoulders

selected = filter_by_body_parts(["chest", "back", "upper legs", "shoulders"])
print(f"Found {len(selected)} exercises for the requested body parts")
for ex in selected[:5]:                     # show first 5 as a preview

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

JavaScript and TypeScript Implementation

For Node.js or browser environments, require the JSON file and use the filter() method:

const exercises = require("./data/exercises.json");

// Filter function
function filterByBodyParts(parts) {
  return exercises.filter(ex => parts.includes(ex.category));
}

// Example usage
const parts = ["chest", "back", "upper legs", "shoulders"];
const selected = filterByBodyParts(parts);
console.log(`Found ${selected.length} matching exercises`);
selected.slice(0, 5).forEach(e => console.log(`- ${e.name} (${e.category})`));

For type-safe filtering in TypeScript, define an interface and cast the imported data:

interface Exercise {
  id: string;
  name: string;
  category: string;
  // …other fields omitted for brevity
}

import exercises from "./data/exercises.json";

function filterByBodyParts(parts: string[]): Exercise[] {
  return (exercises as Exercise[]).filter(e => parts.includes(e.category));
}

const parts = ["chest", "back", "upper legs", "shoulders"];
const result = filterByBodyParts(parts);
console.log(`Matches: ${result.length}`);

SQL Implementation

If you import the data into a relational database, query the category column directly:

SELECT *
FROM exercises
WHERE category IN ('chest', 'back', 'upper legs', 'shoulders');

Interactive Filtering in the Browser

The repository includes index.html, which implements an interactive client-side browser that already performs category filtering in the UI. This file demonstrates the practical application of the filtering logic described above, allowing users to browse the 1,324 exercises by selecting specific body parts from the interface.

Summary

  • Use the category field in data/exercises.json to filter exercises by body part; this is the primary identifier for muscle groups such as chest, back, and upper legs.
  • Reference data/exercises.schema.json for the formal JSON schema definition of the category property.
  • Query across 1,324 records using standard array filtering methods in Python, JavaScript, or SQL—the operation is lightweight and efficient for client-side processing.
  • Consider index.html for a ready-made interactive solution that implements body part filtering without writing custom code.

Frequently Asked Questions

What is the difference between the category and body_part fields?

The body_part field is a duplicate of category maintained for backward compatibility. According to the source code analysis, you should use category as the primary field for new implementations, as it represents the authoritative body part label for each exercise.

Can I filter exercises by multiple body parts simultaneously?

Yes. Pass an array of category strings to your filter function (e.g., ["chest", "back", "upper legs", "shoulders"]). In Python, use ex["category"] in parts; in JavaScript, use parts.includes(ex.category); in SQL, use the IN` operator.

Where is the exercise data physically stored in the repository?

The main dataset resides in data/exercises.json. The formal data structure is defined in data/exercises.schema.json, and documentation including sample records appears in README.md at lines 78-82.

Is there a pre-built web interface to browse exercises by category?

Yes. The index.html file provides an interactive client-side browser that implements body part category filtering. You can open this file directly in a browser to explore the dataset without writing custom filtering code.

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:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →