Rub

Rub info

A Rub (short for Rub al-Hizb) is one-quarter of a Hizb, meaning the Quran has 240 Rub divisions.

Tags

Download Links

About rub metadata

Rub al-Hizb data is exported in both JSON and SQLite formats.

Sample JSON

Here is an example of the JSON structure for the first Rub al-Hizb:

JSON
{
  "1": {
    "rub_number": 1,
    "verses_count": 32,
    "first_verse_key": "1:1",
    "last_verse_key": "2:25",
    "verse_mapping": {
      "1": "1-7",
      "2": "1-25"
    }
  }
}

Field descriptions

Field Type Description
rub_number INTEGER The Rub al-Hizb number (1 to 240).
verses_count INTEGER Total number of verses in the Rub al-Hizb.
first_verse_key TEXT The key of the first verse in the Rub al-Hizb (e.g. 1:1).
last_verse_key TEXT The key of the last verse in the Rub al-Hizb (e.g. 2:25).
verse_mapping OBJECT A mapping of surah numbers to ayah ranges within this hizb. For example, "2": "1-25" indicates that Surah 2 (Al-Baqarah) has verses 1 to 25 in this Rub al-Hizb.

How to use this resource

Download the JSON or SQLite file from the download links on this page. The JSON file is one object: each key is the rub_number as a string ("1" to "240"). The SQLite file has the same fields in the rub table, but verse_mapping is JSON text there. Parse it before you use it.

  • Find the start and end. first_verse_key and last_verse_key (surah:ayah) are the first and last ayah of each rub. Use them as verse_key values in the other QUL resources.
  • Expand verse_mapping. verse_mapping lists the ayahs of this rub in each surah. Each key is a surah number, and each value is a string like "1-141", meaning ayahs 1 to 141, both included. Split it on - and convert both numbers to integers.
JavaScript
// Setup: unzip the download and serve quran-metadata-rub.json from your app (here at /data/)
const items = await fetch('/data/quran-metadata-rub.json').then((res) => res.json());

// Get the first rub
const first = items['1']; // { rub_number: 1, first_verse_key: "1:1", verse_mapping: { ... }, ... }

// Expand verse_mapping into a list of verse keys
const verseKeys = Object.entries(first.verse_mapping).flatMap(([surah, range]) => {
  const [from, to] = range.split('-').map(Number);
  return Array.from({ length: to - from + 1 }, (_, i) => `${surah}:${from + i}`);
});
verseKeys.length === first.verses_count; // true
SQL
-- SQLite: verse_mapping is JSON text. Parse it in your app.
SELECT rub_number, first_verse_key, last_verse_key, verse_mapping
FROM rub
ORDER BY rub_number;

For a longer walkthrough, see Tutorial 7: Quran Metadata End-to-End.