Skip to main content

Datasets

Emoji's are generated into JSON files called datasets, with each dataset being grouped into one of the following: localized data, versioned data, and metadata. These datasets can be found within the emojibase-data package, or loaded from a CDN.

yarn add emojibase-data

JSON files will need to be parsed manually unless handled by a build/bundle process.

Usage

As stated, there are 3 groups of datasets, each serving a specific purpose. The first group, localized data, is exactly that, datasets with localization provided by CLDR (view supported locales). These datasets return an array of emoji objects that adhere to the defined data structure.

import emojis from 'emojibase-data/<locale>/data.json';
import compactEmojis from 'emojibase-data/<locale>/compact.json';
import groupsSubgroups from 'emojibase-data/<locale>/messages.json';

The second group, versioned data, provides datasets for emoji and Unicode release versions. These datasets return a map, with the key being the version, and the value being an array of emoji hexcodes included in the associated release version.

  • emojibase-data/versions/emoji.json - Emoji characters grouped by emoji version.
  • emojibase-data/versions/unicode.json - Emoji characters grouped by Unicode version.
import unicodeVersions from 'emojibase-data/versions/unicode.json';

The third and last group, metadata, provides specialized datasets for unique use cases.

  • emojibase-data/meta/groups.json - A map of non-localized emoji groups (Smileys & People), subgroups (Sky & Weather), and hierarchy, according to the official Unicode data files.
  • emojibase-data/meta/hexcodes.json - A map of emoji hexcodes (hexadecimal codepoints) to an object of hexcodes with different qualified status: fully qualified, minimally qualified, and unqualified.
  • emojibase-data/meta/unicode.json - An array of all emoji unicode characters, including text and emoji presentation characters.
  • emojibase-data/meta/unicode-names.json - A map of hexcodes to official Unicode names for each emoji.
import { groups, subgroups, hierarchy } from 'emojibase-data/meta/groups.json';

Data structure

Each emoji character found within the pre-generated datasets are represented by an object composed of the properties listed below. In an effort to reduce the overall dataset filesize, most property values have been implemented using integers, with associated constants. View the Emoji object for a list of all available fields.

Not all properties will be found in the emoji object, as properties without an applicable value are omitted from the emoji object. This helps to reduce the filesize!

{
annotation: 'man lifting weights',
emoji: '🏋️‍♂️',
gender: 1,
group: 0,
hexcode: '1F3CB-FE0F-200D-2642-FE0F',
order: 1518,
shortcodes: [
'man_lifting_weights',
],
subgroup: 0,
tags: [
'weight lifter',
'man',
],
type: 1,
version: 4,
skins: [
{
annotation: 'man lifting weights: light skin tone',
emoji: '🏋🏻‍♂️',
gender: 1,
group: 0,
hexcode: '1F3CB-1F3FB-200D-2642-FE0F',
order: 1522,
shortcodes: [
'man_lifting_weights_tone1',
],
subgroup: 0,
type: 1,
tone: 1,
version: 4,
},
// ...
],
},

Compact format

While the emoji data is pretty thorough, not all of it may be required, and as such, a compact dataset is supported. View the CompactEmoji object for a list of all available fields.

To use a compact dataset, replace data.json with compact.json.

import data from 'emojibase-data/en/compact.json';
{
annotation: 'man lifting weights',
group: 0,
hexcode: '1F3CB-FE0F-200D-2642-FE0F',
order: 1518,
shortcodes: [
'man_lifting_weights',
],
tags: [
'weight lifter',
'man',
],
unicode: '🏋️‍♂️',
skins: [
{
annotation: 'man lifting weights: light skin tone',
group: 0,
hexcode: '1F3CB-1F3FB-200D-2642-FE0F',
order: 1522,
shortcodes: [
'man_lifting_weights_tone1',
],
unicode: '🏋🏻‍♂️',
},
// ...
],
},

Messages format

The messages format is a special dataset that provides translations for groups, sub-groups, and any other related emoji metadata. The key in each message lines up with a defined TypeScript type alias.

import data from 'emojibase-data/en/messages.json';
{
groups: [
{
key: 'smileys-emotion',
message: 'smileys & emotion',
order: 0,
},
// ...
],
subgroups: [
{
key: 'face-smiling',
message: 'smiling',
order: 0,
},
// ...
],
skinTones: [
{
key: 'light',
message: 'light skin tone',
},
// ...
],
};

Fetching from a CDN

If you prefer to not inflate your bundle size with these large JSON datasets, you can fetch them from our CDN (provided by jsdelivr.com) using fetchFromCDN(), fetchEmojis(), or fetchShortcodes().

import { fetchFromCDN, fetchEmojis, fetchMessages, fetchShortcodes } from 'emojibase';

const englishEmojis = await fetchFromCDN('en/data.json', { shortcodes: ['github'] });
const japaneseCompactEmojis = await fetchEmojis('ja', { compact: true });
const germanCldrShortcodes = await fetchShortcodes('de', 'cldr');
const chineseTranslations = await fetchMessages('zh');

Fetching from your own CDN

If you want to load the JSON datasets from your own CDN, you can customize the cdnUrl using the options object.

When cdnUrl is a string, fetchFromCDN will append '/${path}' to the url. Make sure to include the version within the cdnUrl yourself, it's not added automatically to give you control over its placement.

import { fetchFromCDN, fetchEmojis, fetchMessages, fetchShortcodes } from 'emojibase';

const cdnUrl = 'https://example.com/cdn/emojidata/latest';

const englishEmojis = await fetchFromCDN('en/data.json', { shortcodes: ['github'], cdnUrl });
const japaneseCompactEmojis = await fetchEmojis('ja', { compact: true, cdnUrl });
const germanCldrShortcodes = await fetchShortcodes('de', 'cldr', { cdnUrl });
const chineseTranslations = await fetchMessages('zh', { cdnUrl });

cdnUrl can also be a function, so you have complete control over the format of the url. This function receives path and version as parameters. Version will be what you pass in within the options object, or it will default to latest. Note that version is also used for the cache key, so it's advised to set the option and not hard-code it in the cdnUrl function.

import { fetchFromCDN, fetchEmojis, fetchMessages, fetchShortcodes } from 'emojibase';

function cdnUrl(path: string, version: string): string {
return `https://example.com/cdn/emojidata/${version}/${path}`;
}

const englishEmojis = await fetchFromCDN('en/data.json', { shortcodes: ['github'], cdnUrl });
const japaneseCompactEmojis = await fetchEmojis('ja', { compact: true, cdnUrl });
const germanCldrShortcodes = await fetchShortcodes('de', 'cldr', { cdnUrl });
const chineseTranslations = await fetchMessages('zh', { cdnUrl });

Supported locales

Follow locales are supported for both full and compact datasets.

  • Bengali (bu)
  • Chinese (zh)
  • Chinese, Traditional (zh-hant)
  • Danish (da)
  • Dutch (nl)
  • English (en)
  • English, Great Britain (en-gb)
  • Estonian (et)
  • Finnish (fi)
  • French (fr)
  • German (de)
  • Hindu (hi)
  • Hungarian (hu)
  • Italian (it)
  • Japanese (ja)
  • Korean (ko)
  • Lithuanian (lt)
  • Malay (ms)
  • Norwegian (nb)
  • Polish (pl)
  • Portuguese (pt)
  • Russian (ru)
  • Spanish (es)
  • Spanish, Mexico (es-mx)
  • Swedish (sv)
  • Thai (th)
  • Ukrainian (uk)

Filesizes

Sorted by original size in ascending order.

FileSizeGzipped
zh-hant/data.json674.07 kB84.59 kB
sv/data.json698.15 kB82.79 kB
nb/data.json701.89 kB84.36 kB
zh/data.json708.75 kB93.53 kB
da/data.json710.08 kB86 kB
fi/data.json715.13 kB86.26 kB
et/data.json722.12 kB85.51 kB
es/data.json730.87 kB83 kB
es-mx/data.json732.06 kB83.39 kB
lt/data.json735.13 kB88.48 kB
en/data.json735.59 kB89.22 kB
en-gb/data.json735.59 kB89.22 kB
ja/data.json736.62 kB91.25 kB
ms/data.json743.18 kB86.71 kB
nl/data.json748.35 kB92.29 kB
pt/data.json751.02 kB94.34 kB
hu/data.json761.02 kB93.98 kB
ko/data.json761.63 kB100.11 kB
vi/data.json762.17 kB87.89 kB
fr/data.json764.67 kB95.29 kB
de/data.json768.58 kB97.99 kB
pl/data.json772.79 kB96.72 kB
it/data.json799.19 kB102.82 kB
ru/data.json897.47 kB104.02 kB
th/data.json913.12 kB92.7 kB
uk/data.json931.48 kB106 kB
hi/data.json977.49 kB103.19 kB
bn/data.json1.02 MB102.24 kB