How to Get Exercise Count by Body Part: A Complete Guide

You can get exercise count by body part either by referencing the pre-computed table in README.md or by programmatically aggregating the category field in data/exercises.json using Python, JavaScript, or command-line tools.

The hasaneyldrm/exercises-dataset repository stores 1,324 exercise records as JSON objects, where each entry includes a category field that identifies the target body part. Whether you need a quick reference or want to build custom analytics, this guide shows you exactly how to extract exercise counts by body part using the dataset's built-in resources or your own code.

Understanding the Dataset Structure

Each exercise in data/exercises.json follows a consistent schema where the category field represents the body part targeted by the exercise. According to the repository documentation, the category and body_part fields are identical in this dataset—both describe the anatomical focus of the movement (e.g., "chest", "back", "legs") according to the schema defined in data/exercises.schema.json.

The JSON structure is a flat array of objects, making it straightforward to aggregate counts without complex nesting or joins.

Method 1: Using the Pre-Computed Reference Table

For immediate reference without writing code, consult the Body-Part Statistics table located in README.md at lines 136-149. This table lists every body part alongside its exact exercise count, updated to reflect the current 1,324-exercise collection.

This approach requires no programming—simply open the README and locate the statistics section to see how many exercises exist for chest, back, legs, and other muscle groups.

Method 2: Programmatically Counting Exercises by Body Part

To get exercise count by body part dynamically or to integrate the data into your application, parse data/exercises.json and aggregate the category values. Below are implementations in Python, JavaScript, and Bash.

Python Implementation

Using Python's standard library, load the JSON file and leverage collections.Counter to tally exercises by body part:

import json
from collections import Counter

# Load the full dataset from data/exercises.json

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

# Count by body part using the category field

counts = Counter(ex["category"] for ex in exercises)

# Display results sorted by frequency

for body_part, cnt in counts.most_common():
    print(f"{body_part}: {cnt}")

This script reads the dataset as shown in the repository usage examples, builds a Counter over the category field, and outputs each body part with its corresponding total.

JavaScript/Node.js Implementation

In Node.js environments, require the JSON file directly and use Array.reduce() to aggregate counts:

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

// Aggregate counts by category
const counts = exercises.reduce((acc, ex) => {
  acc[ex.category] = (acc[ex.category] || 0) + 1;
  return acc;
}, {});

console.log(counts);

This approach mirrors the loading pattern shown in the README documentation and produces an object mapping each body part to its exercise count.

Bash and jq One-Liner

For Unix-based systems with jq installed, extract and count body parts using a pipeline:

jq -r '.[] | .category' data/exercises.json | sort | uniq -c | sort -nr

This command extracts the category field from every exercise object, sorts the values, counts unique occurrences, and sorts numerically in reverse to show the most common body parts first.

Key Files and Schema References

When working to get exercise count by body part, these specific files provide the source of truth:

  • data/exercises.json: The master dataset containing 1,324 exercise objects with category fields at the root level.
  • README.md (lines 136-149): Contains the pre-computed table of exercise counts per body part for quick reference.
  • data/exercises.schema.json: Defines the JSON schema including the category and body_part field specifications.

Summary

  • Quick reference: Use the pre-computed table in README.md to instantly see exercise counts by body part.
  • Programmatic access: Load data/exercises.json and aggregate the category field using Python's Counter, JavaScript's reduce(), or Bash with jq.
  • Field consistency: The category and body_part fields contain identical values, so either can be used for counting.
  • Total volume: The dataset contains 1,324 exercises across multiple body parts as defined in the JSON schema.

Frequently Asked Questions

What is the difference between the category and body_part fields?

In the hasaneyldrm/exercises-dataset repository, the category and body_part fields are identical—both describe the body part targeted by the exercise (such as "chest" or "back"). You can use either field interchangeably when writing aggregation logic to get exercise count by body part.

How many total exercises are available for counting?

The dataset contains 1,324 exercises stored as individual JSON objects in data/exercises.json. Each object represents a distinct exercise with associated metadata including the target body part in the category field.

Can I combine body part counting with equipment filtering?

Yes. Since each exercise object contains both category (body part) and equipment fields, you can extend the counting logic to filter by equipment type before aggregating. For example, modify the Python list comprehension to ex["category"] for ex in exercises if ex["equipment"] == "dumbbell" to count only dumbbell exercises per body part.

Where is the data schema formally defined?

The JSON schema defining all fields—including category, body_part, and equipment—is located in data/exercises.schema.json. This file validates the structure of data/exercises.json and ensures that body part classifications remain consistent across the dataset.

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 →