AI Emotion Detector — Detect Emotion in Text
Paste any English text to see which emotions it carries — anger, fear, joy, sadness, surprise, trust and more — with an intensity bar for each and a dominant-emotion verdict. The NRC EmoLex pass runs server-side with no upload to a third-party UI and no model download to your browser.
How it works
The page runs two independent analyses on the same text and shows both. They use very different methods, and watching them agree (or disagree) is the fastest way to judge how much weight a single reading deserves.
1. NRC EmoLex lexicon (always on, deterministic)
The baseline is a word-by-word lookup against a curated subset of the NRC Word-Emotion Association Lexicon(EmoLex) by Saif M. Mohammad and Peter D. Turney, which maps English words to Robert Plutchik's eight primary emotions: anger, anticipation, disgust, fear, joy, sadness, surprise, and trust. A single word can carry several — "reject", for instance, maps to anger, disgust, fear, and sadness at once. The steps:
- Normalise, lowercase, strip punctuation, split into words, drop stop-words.
- For every word found in the lexicon, add 1 to each emotion it is associated with.
- Sum the per-emotion counts:
raw[e] = Σ assoc(word, e). - Normalise to a 0–100 intensity against the peak emotion:
score[e] = round(100 × raw[e] / maxRaw). - The dominant emotion is the one with the highest count; ties break by Plutchik wheel order. If every count is zero, the verdict is neutral.
Normalising against the peak emotion rather than the word count keeps a one-line message and a long paragraph visually comparable — the leading emotion always reads 100, the rest scale beneath it. The whole pass is pure, deterministic JavaScript with no external call, so it always runs, and every word that contributed is listed so the score is never a black box. As a built-in sanity check the tool recomputes the dominant emotion from the normalised intensities and confirms it equals the one found from the raw counts — they always agree by construction.
2. Neural model (server-side, when enabled)
When the server has the Hugging Face Inference API configured, the page also posts the text to j-hartmann/emotion-english-distilroberta-base, a DistilRoBERTa model fine-tuned on six emotion datasets. It returns a probability across seven Ekman classes (anger, disgust, fear, joy, neutral, sadness, surprise), which the page shows as its own set of bars. The two taxonomies — Plutchik's eight and Ekman's seven — are displayed side by side and never merged, because there is no honest one-to-one mapping between them (Ekman has "neutral" but no trust or anticipation). If the token is absent or the call times out after 25 seconds, the page returns the lexicon result alone with a plain note — never a dead screen.
3. Per-sentence breakdown
Switch granularity to "Per sentence" and the text is split on terminal punctuation, then each sentence is scored separately. This surfaces swings the overall verdict hides — a warm email with one fearful line buried in it, a flat update that turns sharp at the end. Fragments shorter than eight characters are dropped so stray abbreviations do not get their own row.
Worked examples
Frequently asked questions
Sources & references
- NRC Word-Emotion Association Lexicon (EmoLex) — Mohammad & Turney
- Hugging Face — emotion-english-distilroberta-base (model card)
- Sanh et al., 2019 — DistilBERT: a distilled version of BERT (arXiv:1910.01108)
- Robert Plutchik — Plutchik's wheel of emotions (8 primary emotions, 1980)
- Hugging Face Inference API — official documentation
The curated EmoLex subset, model card, and API endpoint were last cross-checked on 2026-06-07. The page is reviewed whenever the Hugging Face Inference API contract changes or the lexicon subset is revised. The NRC lexicon is free for research and non-commercial use; only an open subset is shipped here, with attribution.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a misclassification, edge case, or have a model suggestion?
Email me at [email protected] — most fixes ship within 24 hours.