Visualizing Entities With displaCy
Render entity highlights in text.
Visualizing Entities With displaCy is a free NLP Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the NLP Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
See, Don't Just Print
Reading raw tuples gets tiring fast. displaCy paints entities right onto your sentence with colored highlights. 🎨
It Comes Built In
displaCy ships inside spaCy, so there is nothing extra to install. Import it straight from the spacy package.
from spacy import displacyThe ent Style
displaCy has two modes. For named entities you pick style="ent", which boxes and labels each detected span.
Render in a Notebook
Inside Jupyter, call displacy.render to draw the highlighted text right below your cell, no browser needed.
displacy.render(doc, style="ent")Serve in a Browser
Outside a notebook, displacy.serve starts a tiny local web server so you can view the visualization in your browser.
displacy.serve(doc, style="ent")Get the Raw HTML
Need to embed the result in a report? Pass jupyter=False to get back an HTML string you can save or paste.
html = displacy.render(doc, style="ent", jupyter=False)Color by Label
Each entity type gets its own color, so PERSON, ORG, and DATE stand apart at a glance. Color makes patterns obvious.
Customize the Palette
Pass an options dict to recolor labels or limit which types show. Great for branded or focused visualizations.
options = {"colors": {"ORG": "#1565C0"}}Filter the Types
Only care about people? The options dict accepts an ents list so displaCy renders just those labels and hides the rest.
options = {"ents": ["PERSON", "GPE"]}Visualize Many Docs
Pass a list of Docs to render them all at once, perfect for eyeballing entities across a whole batch of sentences.
displacy.render([doc1, doc2], style="ent")A Debugging Superpower
Visualizing entities quickly reveals what the model missed or mislabeled, far faster than scrolling through printed output. 🔍
Quick Check
Which style draws named-entity highlights?
Recap
displaCy with style="ent" highlights entities by color. Render in notebooks, serve in browsers, and tweak with options. ✅
Frequently asked questions
Is the “Visualizing Entities With displaCy” lesson free?
Yes — the full text of “Visualizing Entities With displaCy” is free to read here on the web, and the NLP Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the NLP Academy course, upgrade to CoddyKit PRO.
What will I learn in “Visualizing Entities With displaCy”?
Render entity highlights in text. You practise NLP Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start NLP Academy?
No prior experience is required. NLP Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Visualizing Entities With displaCy” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this NLP Academy lesson?
Yes. Every NLP Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- What Counts as an Entity?
- Extracting Entities With spaCy
- Visualizing Entities With displaCy
- Adding Custom Entity Rules