Skip to main content

CGPA Calculator

A lightweight JavaScript library for calculating GPA (Grade Point Average), CGPA (Cumulative GPA), and SGPA (Semester GPA).

Try the online version at gpacalc.app

Installation

npm install cgpa-calculator

Quick Start

const { calculateGPA, calculateCGPA, gpaToLetter } = require('cgpa-calculator');

// Calculate semester GPA
const gpa = calculateGPA([
  { grade: 'A', credits: 4 },
  { grade: 'B+', credits: 3 },
  { grade: 'A-', credits: 3 },
  { grade: 'B', credits: 2 }
]);

console.log(gpa); // 3.58
console.log(gpaToLetter(gpa)); // 'B+'

API

calculateGPA(courses, options?)

Calculate GPA from a list of courses.

const gpa = calculateGPA([
  { grade: 'A', credits: 3 },
  { grade: 'B', credits: 4 }
], { scale: '4.0' });

Parameters:

  • courses - Array of { grade: string | number, credits: number }
  • options.scale - Grading scale: '4.0' (default) or '5.0'

calculateCGPA(semesters, options?)

Calculate cumulative GPA across multiple semesters.

const cgpa = calculateCGPA([
  [{ grade: 'A', credits: 3 }, { grade: 'B', credits: 4 }],
  [{ grade: 'A-', credits: 3 }, { grade: 'B+', credits: 3 }]
]);

calculateSGPA(courses, options?)

Alias for calculateGPA. Calculate a single semester's GPA.

percentageToGPA(percentage, scale)

Convert percentage score to GPA.

percentageToGPA(85, '4.0'); // 3.5
percentageToGPA(92, '5.0'); // 5.0

gpaToLetter(gpa)

Convert numeric GPA to letter grade.

gpaToLetter(3.5); // 'B+'
gpaToLetter(4.0); // 'A'

getGradePoint(grade, scale)

Get the numeric value for a letter grade.

getGradePoint('A', '4.0'); // 4.0
getGradePoint('B+', '5.0'); // 4.0

Supported Grade Scales

4.0 Scale

Grade Points
A+/A 4.0
A- 3.7
B+ 3.3
B 3.0
B- 2.7
C+ 2.3
C 2.0
C- 1.7
D+ 1.3
D 1.0
F 0.0

5.0 Scale

Grade Points
A+/A 5.0
A- 4.5
B+ 4.0
B 3.5
C+ 2.5
C 2.0
D 1.0
F 0.0

Online Calculator

For a visual, interactive GPA calculator, visit gpacalc.app.

Related Resources

GPA Calculator -- Free online GPA, CGPA, and SGPA calculator for students worldwide.

Also available for:

Learn more:

License

MIT

Release files for cgpa-calc 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cgpa-calc 1.0.1
File Size Uploaded
cgpa_calc-1.0.1.tar.gz 3.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cgpa-calc 1.0.1
File Interpreter ABI Platform
cgpa_calc-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 7.0 kB

Release files / cgpa_calc-1.0.1.tar.gz

Download URL cgpa_calc-1.0.1.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a3cffbdc4de62596f3e040a63ab0aa4f781d4aa1ede09c6200eb51c70caa7015
BLAKE2b-256 checksum
How to use checksums
0fb6f4d76d2db6b0fb4528a5eec128a433097fbd7fdaded634d1d227841342db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / cgpa_calc-1.0.1-py3-none-any.whl

Download URL cgpa_calc-1.0.1-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8e2323290958272404a28325b509dd988dbdbca9a15f1a15557e05dc45ad96a6
BLAKE2b-256 checksum
How to use checksums
3c158e5df181afd8790bcf51b03eac73316dbf1a4f92be527f54994409086861
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page