Skip to content
masterclassBuddyTech Buzz5 fresh blogs ยท 5:00 AM IST

Zod ยท Module

.emoji

z.emoji() validates a single emoji character in current Zod. It accepts complete emoji, including keycap sequences, while rejecting component-only strings such as 123.

Since
4.6

How it works

In current Zod, z.emoji() is a top-level string-format schema that validates a single emoji character. Parsing succeeds for emoji input and fails for non-emoji text; custom error messages can be supplied through the options object.

Syntax

z.emoji(options?)

Parameters

NameTypeDescription
optionsobjectOptions object for configuring the schema, including a custom validation message.

Returns

A Zod schema that validates a single emoji character.

Key points

  • Use z.emoji() as the dedicated schema for one emoji character.
  • Parsing a pictographic emoji such as ๐Ÿ˜€ succeeds.
  • Keycap sequences are accepted when the keycap supplies the required emoji anchor.
  • Flag, subdivision-flag, skin-tone-modified, and ZWJ emoji sequences retain their documented behavior.

Common mistakes

  • In Zod 4.6, component-only strings such as digits, symbols, joiners, variation selectors, and skin-tone modifiers are rejected rather than treated as complete emoji.
  • A valid value must contain an emoji anchor: a pictograph, regional indicator, or keycap.

Example: Validate an emoji

import { z } from "zod";

const Emoji = z.emoji();

console.log(Emoji.parse("๐Ÿ˜€"));
console.log(Emoji.safeParse("hello").success);

Creates a schema that accepts a single emoji and rejects ordinary non-emoji text.

When to use it

Emoji-only input

Accept only emoji values in a user profile, reaction, or label field.

Unicode input validation

Reject incomplete Unicode emoji components before storing or displaying user content.

Boundary validation

Use a schema parser to validate emoji values at API or form boundaries.

Interview questions

QWhat does z.emoji() validate?

z.emoji() is the current top-level Zod schema for validating a single emoji character. It replaces the legacy chained string form shown in older documentation.

Follow-up: What changed in the migration? String formats became subclasses of ZodString, and formats such as emoji moved to the top-level z namespace.

QWhich inputs should a developer expect to fail?

It accepts a complete emoji such as ๐Ÿ˜€ and rejects ordinary text such as hello. In the current behavior, component-only strings are also rejected.

Follow-up: Why is 123 rejected even though some characters can participate in emoji sequences? They are components without the required pictograph, regional-indicator, or keycap anchor.

QHow is the schema used in application code?

The schema can be constructed directly with z.emoji() and parsed with the normal Zod parsing APIs. The documentation also shows that string-format schemas can be moved to the top-level namespace.

Follow-up: How would you customize the validation error? Pass an options object with a message, for example z.emoji({ message: "Expected an emoji" }).

  • z.string()
  • z.email()
  • z.url()
  • z.uuid()
  • z.regex()

Source: Zod 4.6. Checked 2026-10-15.