The compositionend event fires when an IME (Input Method Editor) or other text composition system completes or cancels a composition session. Learn addEventListener vs oncompositionend, CompositionEvent.data, how it pairs with compositionstart / compositionupdate, and five try-it labs.
01
Kind
Instance event
02
Type
CompositionEvent
03
When
IME session ends
04
Handler
oncompositionend
05
Key field
event.data
06
Status
Baseline widely available
Fundamentals
Introduction
Languages such as Chinese, Japanese, and Korean often use an IME. The user types phonetic or stroke hints; the system shows candidates; then a final character (or string) is committed into the field.
That whole flow is a composition session. compositionend means the session finished—either the text was committed or the composition was canceled. MDN’s classic example is finishing a Chinese character with a Pinyin IME.
💡
Beginner tip
During composition, treat intermediate text as temporary. Use compositionend (and/or input with isComposing === false) when you need the final committed characters.
Concept
Understanding compositionend
An instance event that answers: “Did the IME composition session just finish or get canceled?”
Fires when composition completes or is canceled.
CompositionEvent — read data (and sometimes locale).
Siblings — compositionstart, compositionupdate.
Useful for custom editors, search-as-you-type, and validation after IME commit.
Baseline Widely available on MDN (since July 2015).
Foundation
📝 Syntax
Use the event name with addEventListener, or set the handler property:
A CompositionEvent (inherits from UIEvent and Event).
Event properties
Property
Meaning
data
Characters generated by the input method for this event
locale
Locale of the current input method (when available)
Sequence
🔁 Composition Session Flow
compositionstart — the IME session begins.
compositionupdate — candidate / composing text changes (may fire many times).
compositionend — session completes or is canceled; check event.data.
Ordinary Latin typing may never fire these events. They matter most when an IME is active.
Compare
⚖️ Composition vs input / beforeinput
API
Role during IME
composition*
Session lifecycle (start / update / end)
beforeinput
Edit about to apply; isComposing may be true
input
Value changed; may fire during and after composition
Cheat Sheet
⚡ Quick Reference
Goal
Code / note
Listen
el.addEventListener("compositionend", fn)
Handler property
el.oncompositionend = fn
Committed text
event.data
Log full IME flow
Also listen to start + update
MDN status
Baseline Widely available (Jul 2015)
Snapshot
🔍 At a Glance
Four facts to remember about compositionend.
Event type
CompositionEvent
data + locale
Means
IME done
Complete or cancel
Pair with
start/update
Full session
Baseline
yes
Widely available
Hands-On
Examples Gallery
Examples follow MDN Element: compositionend event. To see live IME events, enable an IME (for example macOS Option+`, Windows Win+., or a CJK keyboard).
📚 Getting Started
Log generated characters when composition ends (MDN style).
Example 1 — addEventListener("compositionend")
MDN idea: print the characters produced when the IME session finishes.
compositionend is marked Baseline Widely available on MDN (since July 2015). Logos use the shared browser-image-sprite.png sprite from this project. Exact IME UI and shortcuts still depend on the operating system and language pack.
✓ Baseline · Widely available
Element compositionend
Works across modern desktop and mobile browsers for IME composition session completion.
100%Widely available
Google ChromeSupported · Desktop & Android
Full support
Mozilla FirefoxSupported · Desktop & Android
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
OperaSupported · Modern versions
Full support
Internet ExplorerSupported (legacy)
Supported
compositionendBaseline
Bottom line: Listen for compositionend when you need the final IME-committed characters; pair with start/update for the full session.
Wrap Up
Conclusion
compositionend is the “IME session finished” signal. Read event.data, pair it with start/update when debugging, and avoid treating intermediate composing text as final user input.
Defer search/validation until composition ends when using IMEs
Log start/update/end together while debugging
Check event.data and the control value
Test with a real IME keyboard layout
❌ Don’t
Assume composition events fire for plain Latin typing
Treat every input during IME as final text
Ignore cancel paths (empty or unexpected data)
Confuse composition with the everyday input event
Overwrite oncompositionend if you need multiple listeners
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about compositionend
IME session finished—read data, then treat text as committed.
5
Core concepts
🌐01
IME finished
complete or cancel
Event
📄02
CompositionEvent
data + locale
API
🔁03
After update
end of session
Order
🔎04
Skip mid-IME
search later
Pattern
🎯05
Baseline
widely available
Compat
❓ Frequently Asked Questions
It fires when a text composition system such as an Input Method Editor (IME) completes or cancels the current composition session — for example after finishing a Chinese character with a Pinyin IME.
No. MDN marks Element compositionend as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard.
A CompositionEvent (inherits from UIEvent). Useful properties include data (characters generated) and locale (input method locale).
compositionstart begins a session, compositionupdate fires as the candidate text changes, and compositionend fires when the session completes or is canceled.
On macOS you can often use Option + ` to open an IME panel; on Windows, Win + . opens emoji/IME-related UI. Exact shortcuts depend on OS language settings. You can also switch to a CJK keyboard layout.
Often yes for custom editors. During composition, InputEvent.isComposing may be true. Wait for compositionend before treating text as final committed characters.
Did you know?
MDN’s demo tips for opening IME UI: on macOS try Option+`; on Windows try Win+.. Your OS language settings still control which IMEs are installed.