Free and open source · npm

CodexParser

A Bible reference parser for JavaScript. It finds references in running text, parses them into structured passages, checks that the verses exist, and converts Old Testament references between English, Hebrew and Septuagint verse numbering.

Try it

Type or paste any text. The package runs here in your browser, exactly as published (version 0.7.4).

Old Testament references also show their Hebrew and Septuagint numbers.

Rewritten with SBL abbreviations:

Install

npm install codexparser

It has no dependencies, ships TypeScript declarations, and loads with either require or import.

Find and parse references

import CodexParser from "codexparser"

const text = "Preaching through Jn 3:16-18 tonight; compare Ps 51:1-4 and Mal 4:5."
const parser = new CodexParser()
parser.parse(text)

parser.getPassages().map((p) => p.scripture.passage)
// [ "John 3:16-18", "Psalms 51:1-4", "Malachi 4:5" ]

parser.replace(text)
// "Preaching through John 3:16-18 tonight; compare Ps. 51:1-4 and Mal. 4:5."

Every passage records where it was found: for "As Paul says (Rom 8:28), and see 1 Cor 13:4-7." the first passage has startIndex 14, endIndex 22 and originalText "Rom 8:28", so a link or highlight can be placed on the exact characters.

Validate

new CodexParser().parse("John 3:37").getPassages()[0].valid
// { error: true, code: 104, message: { content: "Verse number 37 does not exist in John 3", ... } }

Convert between English, Hebrew and Greek numbering

Old Testament verse numbers are not the same in English Bibles, the Hebrew Bible and the Septuagint. CodexParser carries the correspondences, so a reference can be converted in either direction.

const [ps] = new CodexParser().parse("Psalm 51:1").getPassages()
ps.passages[0].versification   // { lxx: "50:3", mt: "51:3", eng: "51:1" }
ps.getLXX().scripture.cv       // "50:3"

const [mal] = new CodexParser().parse("Malachi 4:5").getPassages()
mal.convertVersion("mt").scripture.passage   // "Malachi 3:23"

const [x] = new CodexParser().parse("Psalms 94:4-100:6 MT").getPassages()
x.getLXX().scripture.cv
// "93:4-23; 94:1-11; 95:1-13; 96:1-12; 97:1-9; 98:1-9; 99:1-5"

const [est] = new CodexParser().parse("Esther 11:2").getPassages()
est.convertVersion("lxx").scripture.cv          // "1:1a" (Addition A)
est.convertVersion("mt").missingPassages.length // 1: not in the Hebrew

A reference tagged with a version ("Psalm 23:1 LXX") is read in that numbering: it converts to English Psalm 24:1. Theodotion's Daniel has its own numbering as well: English Daniel 4:1 is Hebrew and Theodotion 3:31, and Old Greek 4:34c.

Every difference the parser knows is listed, book by book, on the versification differences page, alongside a verse-by-verse comparison of the Göttingen Septuagint with Rahlfs-Hanhart.

What it handles

  • Single verses, ranges, comma-separated verses, whole chapters, chapter ranges and references that span chapters (Psalm 119:1-120:5).
  • Common abbreviations (Jn, 1 Cor, Ps), and SBL-style abbreviated output.
  • Single-chapter books such as Jude and Obadiah.
  • The deuterocanonical books: Tobit, Judith, Wisdom, Sirach, Baruch, the Letter of Jeremiah, 1 Esdras, 1–4 Maccabees and the Prayer of Manasseh (Sirach 24:1-4 → Sir. 24:1-4 LXX).
  • The Greek additions to Esther and Daniel, Septuagint pluses and minuses (reported in missingPassages), and the Psalm superscriptions, which English Bibles leave unnumbered.

License

ISC. Written by Jeremy Menicucci. Issues and pull requests are welcome on GitHub.