AI Sentiment Analyzer — Free, Server-Side, No Signup
Detect whether any English text reads as positive, negative, or neutral. A DistilBERT classifier runs server-side and an AFINN-111 lexicon runs alongside it as a transparent cross-check. No signup, no upload to a third-party UI, no model download to your browser.
How it works
The page runs two independent analyses on the same input and shows both, side by side. They use very different methods, and watching them agree (or disagree) is the fastest way to judge how trustworthy a single reading is.
1. Transformer model (server-side)
The primary classifier is distilbert/distilbert-base-uncased-finetuned-sst-2-english, a DistilBERT model fine-tuned on the Stanford Sentiment Treebank v2 corpus. We call the Hugging Face Inference API (api-inference.huggingface.co) from a server-only Next.js route handler. The browser never downloads model weights — the only payload it sends is your text, and the only payload it receives is a small JSON result. The same route is reused for batch scoring: the whole text plus each sentence (up to a cap) are sent in one request so we avoid round-trip overhead on longer passages.
The SST-2 head outputs two probabilities (POSITIVE and NEGATIVE) that sum to 1. To get a third "neutral" class without retraining we treat low-confidence outputs as neutral: if the top probability is below 65%, the result is reclassified. The threshold is deliberate — neutral passages tend to push a binary classifier toward 50/50, so the confidence itself is the signal.
2. AFINN-111 lexicon (cross-check, always on)
The second pass is a word-by-word lookup against a curated subset of AFINN-111, the public-domain sentiment lexicon by Finn Årup Nielsen. Tokens are NFKC-normalized, lowercased, stripped of punctuation, and summed against their integer valence scores (-5 ... +5). The sum is divided by token count to give a comparative score; values above +0.15 are positive, below -0.15 are negative, the rest are neutral. The exact formula:
comparative = Σ valence(t) for t in tokens(text)
─────────────────────────────────────
count(tokens(text))
if comparative ≥ +0.15 → positive
if comparative ≤ −0.15 → negative
otherwise → neutralThe AFINN pass is pure JavaScript with no API call, so it always runs even when neural inference is not configured on this build. It is also fully deterministic — the same text always produces the same score — which is useful for spot-checking or for cases where you need a sentiment value you can reproduce offline.
3. Per-sentence breakdown
For inputs of more than one sentence, both passes run separately on each split (terminal punctuation followed by whitespace, or a line break). This surfaces swings the overall label hides — a glowing review with one buried complaint, an otherwise-flat news paragraph that turns sharply at the end. The split drops fragments shorter than eight characters so emojis, abbreviations, and stray punctuation don't get their own row.
Both analyses are deterministic given the same input. The HF Inference API is stateless: every call is independent and we send no identifiers. If the API is rate-limited or unreachable, the lexicon result is still returned so the page never shows a dead state.
Worked examples
Frequently asked questions
Sources & references
- Hugging Face — distilbert-base-uncased-finetuned-sst-2-english (model card)
- Sanh et al., 2019 — DistilBERT: a distilled version of BERT (arXiv:1910.01108)
- Stanford NLP — Sentiment Treebank (SST-2) dataset
- Hugging Face Inference API — official documentation
- AFINN-111 lexicon — Finn Årup Nielsen (CC0 / public domain)
The model card, API endpoint, and lexicon were last cross-checked on 2026-05-12. The page is reviewed whenever the Hugging Face Inference API contract changes or the upstream model repo is re-uploaded.
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.