Text Sentiment Analyzer

A lightweight, privacy-friendly sentiment checker that runs entirely in your browser. Paste text, count positive and negative keywords, and get a normalized score that is easy to inspect and explain.

Introduction: what this sentiment analyzer does

Sentiment analysis is the task of estimating whether a piece of text expresses a positive, negative, or neutral attitude. People do this naturally when reading a review, an email, or a social post, but computers need explicit rules. Many modern systems use machine learning, yet a classic and still useful baseline is lexicon-based sentiment: count words that are commonly associated with positive or negative tone and compare the totals.

This page is a Text Sentiment Analyzer that implements that baseline in plain JavaScript. It is designed for speed, transparency, and privacy. When you click Analyze, the script lowercases your text, splits it into tokens with a simple regular expression, counts matches against a small list of positive and negative keywords, and then computes a normalized score and a label. Because the logic runs in your browser, your text is not uploaded anywhere.

The goal is not to understand meaning the way a human reader does. Instead, the tool gives you a quick and explainable estimate of tone that works well for teaching, for comparing one draft against another, or for scanning short feedback snippets. The breakdown table shows the raw counts, so you can see exactly why the page called a sample positive, neutral, or negative rather than treating the result like a mysterious black box.

How to use the calculator

Start by pasting or typing text into the input field below. Then click Analyze. The result area will report how many positive keywords matched, how many negative keywords matched, how many words were analyzed in total, and what normalized score came out of those counts. If you want a compact summary for a note, report, or message, you can use Copy Result after the analysis finishes.

A practical habit is to analyze sensible chunks rather than an entire long document at once. For example, you might run each review paragraph separately, compare different email drafts, or look at one support response at a time. Lexicon-based methods can hide local shifts in tone when everything is averaged together. A paragraph that sounds warm and helpful can be buried inside a much longer text that is otherwise flat or critical, so smaller units often tell a clearer story.

Formula & decision rule: how the score is calculated

The analyzer counts how many tokens match the positive list, how many match the negative list, and how many tokens were examined overall. If we call the positive count npos, the negative count nneg, and the number of analyzed tokens N, the normalized sentiment score is:

S = n pos n neg N

This normalization matters because it makes scores more comparable across texts of different lengths. A short sample with one positive word and no negative words can feel strongly positive if it only contains a few total tokens. The very same single positive word would matter much less inside a long paragraph of otherwise neutral wording. Dividing by N captures that dilution effect.

The decision rule is intentionally simple. If the score is above 0.05, the page labels the tone positive. If the score is below -0.05, it labels the tone negative. Anything in between is treated as neutral. That small threshold keeps tiny differences from being overinterpreted. Without it, a long neutral paragraph containing just one extra positive word could be mislabeled as clearly positive even when the overall tone is almost balanced.

Tokenization also matters. This implementation lowercases the text, splits on [^a-z]+, and ignores tokens shorter than 2 characters. That keeps the code fast and easy to inspect, but it also means the analyzer focuses on basic English alphabetic words. Numbers, punctuation, many emojis, hashtags, and accented characters are treated as separators rather than core parts of a word.

Default lexicon and what each input really means

The main input on this page is simply your text. There are no extra sliders or advanced settings, so the interpretation happens in the script itself. The positive and negative word lists are the hidden assumptions behind the calculator. In other words, when the tool says a passage is positive, it really means that the passage contains more matches from the positive list than from the negative list after normalizing by total words.

The built-in lexicon is intentionally small. That makes the method transparent, and it keeps the page lightweight enough to run instantly in a browser. The tradeoff is that many emotional words will not be recognized. If your texts live in a specific domain, such as product reviews, classroom feedback, employee check-ins, or social posts, you may want to customize the arrays in the script so the word list reflects the language you actually care about.

For example, a product team might add words like durable, reliable, flimsy, refund, smooth, or buggy. A workplace communication reviewer might add appreciate, blocked, urgent, confusing, collaborative, or dismissive. An academic writing workflow might add robust, novel, weak, unsupported, consistent, or unclear. The calculator becomes more useful when the lexicon matches the domain, but consistency matters just as much as size. A loosely chosen word list can create bias or make comparisons unreliable.

Example entries from the default sentiment lexicon
Polarity Word Part of speech
Positive happy adjective
Positive love verb or noun
Positive wonderful adjective
Negative sad adjective
Negative hate verb
Negative terrible adjective

Worked example: from raw words to final label

Suppose you analyze the sentence below. It mixes praise with criticism, which is exactly the kind of real-world text where a transparent count can be helpful.

I love this product. It is wonderful, but the shipping was terrible.

After lowercasing and tokenization, the analyzer looks for matches in the default keyword lists. In this sentence, it will find love and wonderful in the positive list and terrible in the negative list. That gives npos = 2 and nneg = 1.

If the total number of analyzed tokens is N = 12, then the score is S = (2 - 1) / 12 = 0.083. Because 0.083 is above the positive threshold of 0.05, the final label becomes positive. The wording still contains criticism, but the balance of matched words is slightly more positive than negative when scaled by total length.

That example also shows why raw counts and normalized scores should be read together. If you only looked at the label, you might miss that the text contains both praise and complaint. If you only looked at counts, you might miss how much neutral language was present. Together, the table and the formula tell a fuller story.

How to interpret results responsibly

A lexicon score is best treated as a rough indicator, not a final judgment about author intent. This calculator is most useful when you want a quick baseline, a consistent comparison method, or a teaching example for how keyword-based sentiment works. When you get a result, always look back at the underlying counts and ask whether the matches are meaningful enough to support the label.

If the text is long but the positive and negative counts are both close to zero, the score will also be close to zero. That does not always mean the text is emotionally neutral. It can just mean the lexicon missed the emotional wording. Likewise, a neutral label can hide a mixed passage with strong positive and strong negative signals that happen to balance out. A short sentence can swing sharply because one matched word has a larger effect when N is small.

Repetition is another thing to keep in mind. If someone writes great great great, the analyzer counts each occurrence separately. That can be reasonable because repetition often signals emphasis, but it can also exaggerate spammy or unnatural wording. For editing tasks, the most useful workflow is usually comparative: analyze version A, analyze version B, and then see whether the score, counts, and final label moved in the direction you intended.

Limitations and assumptions

Lexicon-based sentiment is transparent, fast, and easy to explain, but it has well-known blind spots. The most important limitation is that it counts words, not context. A phrase like not good still contains the token good and may therefore look positive even though the overall meaning is negative. Sarcasm creates the same problem. A sentence such as Great, just great can sound clearly negative to a human reader while still producing positive lexical matches.

The method also assumes that the small word lists are appropriate for your domain and audience. Words drift over time, slang changes by community, and some terms flip meaning depending on context. The page does not handle intensity weighting, so excellent and pleasant count the same. It does not handle phrases such as waste of time unless one of the individual words is already in the list. It also uses a simple English-only tokenizer, so it is not suitable for multilingual or Unicode-rich text without modification.

None of those limitations make the tool useless. They just define what it is good for. This calculator is a clear baseline, a learning aid, and a quick browser-side checker. If you need deeper accuracy, you would usually move toward a larger curated lexicon, phrase rules, negation handling, or a machine learning model. Those approaches can be more powerful, but they are often less transparent and may require sending text to a server.

FAQ

Does this tool store or upload my text?

No. The analysis runs locally in your browser. The optional copy feature only sends text to your clipboard when you explicitly click the copy button.

Why does the analyzer ignore emojis, hashtags, or accented characters?

The tokenizer splits on anything that is not a basic English letter from a to z. That keeps the code predictable and easy to inspect, but it also limits language coverage. A Unicode-aware tokenizer would be the next step if you needed broader support.

What should I do if everything comes out neutral?

That usually means your text contains few words from the default lists. Try adding domain-specific terms to the script, or test a sentence that includes known words such as wonderful, excellent, terrible, or awful. Of course, some text is genuinely neutral too, especially instructions, updates, and factual descriptions.

Can I use this for research or moderation?

You can use it for quick exploration, teaching, or prototyping, but it is not a substitute for a validated sentiment model. If you use it in a formal workflow, document the lexicon, tokenization rules, thresholds, and known limitations so the results are reproducible and interpreted carefully.

The analyzer counts positive and negative keywords to estimate tone. No data leaves your browser.

Enter text and click Analyze.

Clipboard status messages will appear here after you use Copy Result.

Optional mini-game: Sentiment Sort Sprint

If you want a faster feel for how this calculator works, try the mini-game below. Instead of pasting full text, you classify individual word cards as negative, neutral, or positive when they hit the scan line. The mechanic mirrors the calculator itself: positive words raise the tone signal, negative words lower it, and neutral filler adds total word count without pushing sentiment in either direction.

The round lasts about 75 seconds. On desktop, use left arrow for negative, down arrow for neutral, and right arrow for positive. On touch screens, tap the matching lane pad at the bottom of the canvas. Every 18 to 24 seconds the pace changes with a twist such as a neutral-noise surge, a burst of extra cards, or a faster scan. Your best score is saved in local storage on this device only.

Score0
Time75s
Streakx0
Progress0%

Sentiment Sort Sprint

Read the incoming word cards and classify them when they cross the scan line. Tap the colored pads or use keyboard arrows.

  • Use ← for negative, ↓ for neutral, and → for positive.
  • Correct timing builds your streak and boosts your score.
  • Twists add bursts, speed, or neutral noise to show how filler words can dilute a normalized sentiment score.

Best score: 0

Optional training game: practice separating positive, neutral, and negative words without changing the calculator result above.

Embed this calculator

Copy and paste the HTML below to add the Text Sentiment Analyzer (Lexicon-Based) | AgentCalc to your website.