Last updated
Quick Reference
- Shortcode is found in the URL: instagram.com/p/SHORTCODE/
- Instagram Base64 alphabet: A-Z (0-25), a-z (26-51), 0-9 (52-61), - (62), _ (63)
- Instagram epoch: January 1, 2011 (Unix: 1293840000)
- Timestamp extracted by right-shifting media ID by 23 bits
- Works for posts, reels, and IGTV — not for stories (they expire)
- No API access or authentication required
Paste any Instagram post URL or shortcode to instantly decode its creation date.
Examples
Example 1: Finding the Shortcode in a Post URL
Instagram post URL format:
https://www.instagram.com/p/SHORTCODE/
Examples:
https://www.instagram.com/p/CxYz123abc/ → shortcode: CxYz123abc
https://www.instagram.com/p/B1a2b3c4d5e/ → shortcode: B1a2b3c4d5e
https://www.instagram.com/reel/CxYz123abc/ → shortcode: CxYz123abc (reels use same format)
The shortcode is always:
- Located between /p/ and the trailing /
- Alphanumeric characters, hyphens, and underscores
- Typically 11 characters for modern posts
- Shorter for older posts (Instagram's early posts had 8-9 character codes)
Example 2: How Shortcode Decoding Works
Step 1: Convert shortcode to numeric media ID
Instagram's Base64 alphabet:
A-Z = 0-25
a-z = 26-51
0-9 = 52-61
- = 62
_ = 63
Example shortcode: "CxYz123abc"
Each character → 6-bit value:
C → 2 → 000010
x → 49 → 110001
Y → 24 → 011000
z → 51 → 110011
1 → 53 → 110101
2 → 54 → 110110
3 → 55 → 110111
a → 26 → 011010
b → 27 → 011011
c → 28 → 011100
Concatenate bits → 60-bit integer → numeric media ID
Step 2: Extract timestamp from media ID
timestamp_seconds = (media_id >> 23) + 1293840000
created_at = new Date(timestamp_seconds * 1000)
Example 3: JavaScript Implementation
const INSTAGRAM_EPOCH = 1293840000; // Jan 1, 2011
// Instagram's Base64 alphabet
const ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
function shortcodeToMediaId(shortcode) {
let id = 0n;
for (const char of shortcode) {
const value = ALPHABET.indexOf(char);
if (value === -1) throw new Error(`Invalid character: ${char}`);
id = id * 64n + BigInt(value);
}
return id;
}
function decodeShortcode(shortcode) {
// Remove URL if full URL was pasted
const match = shortcode.match(/\/p\/([A-Za-z0-9_-]+)/);
const code = match ? match[1] : shortcode;
const mediaId = shortcodeToMediaId(code);
const timestampSeconds = Number(mediaId >> 23n) + INSTAGRAM_EPOCH;
const createdAt = new Date(timestampSeconds * 1000);
return {
shortcode: code,
mediaId: String(mediaId),
createdAt,
iso: createdAt.toISOString()
};
}
// Usage:
const result = decodeShortcode('CxYz123abc');
console.log(result.iso); // "2023-08-15T14:32:07.000Z"
console.log(result.mediaId); // "2847392847392847392"
// Also works with full URLs:
const result2 = decodeShortcode('https://www.instagram.com/p/CxYz123abc/');
console.log(result2.iso); // Same result