DIGIPIN Algorithm: How India's Digital Address System Works

A deep dive into the grid, code, and step-by-step logic behind India's geo-coded address revolution.

DIGIPIN Algorithm FAQ: Common Search Queries

Get your DIGIPIN | Find address by DIGIPIN

What is DIGIPIN? (Digital Postal Index Number Explained)

DIGIPIN (Digital Postal Index Number) is India's standardized, open-source, geo-coded addressing system, developed by the Department of Posts in collaboration with IIT Hyderabad, NRSC, and ISRO. It divides the country into uniform 4m x 4m grid cells, each assigned a unique 10-character alphanumeric code derived from latitude and longitude. DIGIPIN is strictly a function of location, ensuring privacy and offline usability, and is the foundation of India's National Addressing Grid.

DIGIPIN Grid Structure, Code Levels & Bounding Box

The DIGIPIN system overlays a logical grid on the entire territory of India, using a bounding box from 63.5°E to 99.5°E longitude and 2.5°N to 38.5°N latitude (EPSG:4326). This grid is recursively divided into 16 regions at each level, with each cell at level 10 representing a 3.8m x 3.8m area. The grid aligns with Survey of India's toposheets and includes India's maritime EEZ, making it suitable for land and sea addresses.

Code Length Grid Size (approx.)
1 1000 km
2 250 km
3 62.5 km
4 15.6 km
5 3.9 km
6 1 km
7 250 m
8 60 m
9 15 m
10 3.8 m

DIGIPIN Code Architecture, Symbol Set & Hierarchical Encoding

Each DIGIPIN is a 10-character code using 16 symbols: 2, 3, 4, 5, 6, 7, 8, 9, C, J, K, L, M, P, F, T. The code is built hierarchically: the bounding box is split into 16 regions (level 1), each further split into 16 subregions (level 2), and so on for 10 levels. Each character in the code identifies a subregion at that level, uniquely pinpointing a 4m x 4m cell anywhere in India.

const DIGIPIN_SYMBOLS = ["2", "3", "4", "5", "6", "7", "8", "9", "C", "J", "K", "L", "M", "P", "F", "T"];

How to Generate DIGIPIN: Step-by-Step Encoding (Latitude/Longitude to DIGIPIN)

  1. Start with the bounding box: 63.5°E to 99.5°E longitude, 2.5°N to 38.5°N latitude.
  2. For each of 10 levels:
    • Divide the current box into 16 (4x4) subregions.
    • Find which subregion contains your (lat, lon).
    • Append the corresponding symbol to the code.
    • Update the bounding box to this subregion for the next level.
  3. After 10 levels, you have a unique 10-character code for your location.

This process is deterministic and reversible, ensuring every location in India has a unique, permanent DIGIPIN.

How to Decode DIGIPIN: Step-by-Step (DIGIPIN to GPS Coordinates)

  1. Remove hyphens from the code (if any) and ensure it is 10 characters.
  2. Start with the full bounding box.
  3. For each character in the code:
    • Find the corresponding subregion in the 4x4 grid.
    • Update the bounding box to this subregion.
  4. After 10 levels, the center of the final box is your decoded latitude/longitude.

This allows you to convert any valid DIGIPIN back to its precise GPS coordinates.

DIGIPIN Algorithm Code Examples (with Annotations)

DIGIPIN Encoding Function (JavaScript Example)

function encodeDIGIPIN(lat, lon) {
  const L = [
    ["F", "C", "9", "8"],
    ["J", "3", "2", "7"],
    ["K", "4", "5", "6"],
    ["L", "M", "P", "T"]
  ];
  let vDIGIPIN = "";
  let MinLat = 2.5, MaxLat = 38.5, MinLon = 63.5, MaxLon = 99.5;
  let LatDivBy = 4, LonDivBy = 4;
  if (lat < MinLat || lat > MaxLat || lon < MinLon || lon > MaxLon) return "";
  for (let Lvl = 1; Lvl <= 10; Lvl++) {
    let LatDivDeg = (MaxLat - MinLat) / LatDivBy;
    let LonDivDeg = (MaxLon - MinLon) / LonDivBy;
    let row = 0, column = 0;
    let NextLvlMaxLat = MaxLat;
    let NextLvlMinLat = MaxLat - LatDivDeg;
    for (let x = 0; x < LatDivBy; x++) {
      if (lat >= NextLvlMinLat && lat < NextLvlMaxLat) {
        row = x;
        break;
      } else {
        NextLvlMaxLat = NextLvlMinLat;
        NextLvlMinLat = NextLvlMaxLat - LatDivDeg;
      }
    }
    let NextLvlMinLon = MinLon;
    let NextLvlMaxLon = MinLon + LonDivDeg;
    for (let x = 0; x < LonDivBy; x++) {
      if (lon >= NextLvlMinLon && lon < NextLvlMaxLon) {
        column = x;
        break;
      } else if (NextLvlMinLon + LonDivDeg < MaxLon) {
        NextLvlMinLon = NextLvlMaxLon;
        NextLvlMaxLon = NextLvlMinLon + LonDivDeg;
      } else {
        column = x;
      }
    }
    vDIGIPIN += L[row][column];
    if (Lvl === 3 || Lvl === 6) vDIGIPIN += "-";
    MinLat = NextLvlMinLat;
    MaxLat = NextLvlMaxLat;
    MinLon = NextLvlMinLon;
    MaxLon = NextLvlMaxLon;
  }
  return vDIGIPIN;
}

DIGIPIN Decoding Function (JavaScript Example)

function decodeDIGIPIN(vDigiPin) {
  vDigiPin = vDigiPin.replace(/-/g, "");
  if (vDigiPin.length !== 10) return null;
  const L = [
    ["F", "C", "9", "8"],
    ["J", "3", "2", "7"],
    ["K", "4", "5", "6"],
    ["L", "M", "P", "T"]
  ];
  let MinLat = 2.5, MaxLat = 38.5, MinLng = 63.5, MaxLng = 99.5;
  let LatDivBy = 4, LngDivBy = 4;
  let LatDivVal = 0, LngDivVal = 0;
  let ri, ci, f;
  let Lat1, Lat2, Lng1, Lng2;
  for (let Lvl = 0; Lvl < 10; Lvl++) {
    ri = -1; ci = -1; f = 0;
    const digipinChar = vDigiPin.charAt(Lvl);
    LatDivVal = (MaxLat - MinLat) / LatDivBy;
    LngDivVal = (MaxLng - MinLng) / LngDivBy;
    for (let r = 0; r < LatDivBy; r++) {
      for (let c = 0; c < LngDivBy; c++) {
        if (L[r][c] === digipinChar) {
          ri = r; ci = c; f = 1; break;
        }
      }
      if (f) break;
    }
    if (f === 0) return null;
    Lat1 = MaxLat - LatDivVal * (ri + 1);
    Lat2 = MaxLat - LatDivVal * ri;
    Lng1 = MinLng + LngDivVal * ci;
    Lng2 = MinLng + LngDivVal * (ci + 1);
    MinLat = Lat1; MaxLat = Lat2;
    MinLng = Lng1; MaxLng = Lng2;
  }
  const CLat = (Lat2 + Lat1) / 2;
  const CLng = (Lng2 + Lng1) / 2;
  return { lat: CLat, lon: CLng };
}

Worked Example: Dak Bhawan, New Delhi

Let's encode the coordinates of Dak Bhawan (28.622788°N, 77.213033°E):

  1. Start with the full bounding box.
  2. At each level, find the subregion for the coordinates and append the symbol.
  3. After 10 levels, you get the DIGIPIN for Dak Bhawan: 39J-49L-L8T4.

This process is illustrated in the official India Post technical document (see Figure 4).

DIGIPIN Algorithm FAQ & Help

Is DIGIPIN open-source and privacy-friendly?
Yes, the algorithm is open-source and does not store any personal data—only location information.
Can I use DIGIPIN for any location in India?
Yes, as long as the coordinates are within the bounding box (63.5°E–99.5°E, 2.5°N–38.5°N).
How accurate is DIGIPIN?
A 10-character DIGIPIN pinpoints a 3.8m x 3.8m area, making it highly precise for navigation, deliveries, and more.
Where can I find the official documentation?
See the India Post DIGIPIN Technical Document (PDF).

References & Further Reading

Content based on the official India Post DIGIPIN technical document and open-source code. For educational purposes.