I've been working on this iOS app recently and I encountered a (rather easily solved) problem: How do I determine if my string is comprised only of emojis?

Well, that's your job today!


A string. If the presence of unicode characters is problematic for you then you may use a different reasonable format. Please state what you do if you do something different from a regular string for taking input.


Print or return a truthy value if the input string contains only emojis, and a falsey value if it contains any characters other than emojis.

Wait a sec... what's an emoji? ๐Ÿ˜…

An emoji is a character that falls in these ranges:

0x1F600...0x1F64F  // Emoticons
0x1F300...0x1F5FF  // Misc Symbols and Pictographs
0x1F680...0x1F6FF  // Transport and Map
0x2600...0x26FF    // Misc symbols
0x2700...0x27BF    // Dingbats
0xFE00...0xFE0F    // Variation Selectors

(I think)

This is ๐Ÿ”น๐Ÿ”น, so shortest code in bytes winsโ•

Test cases

"Is it an emoji? ๐Ÿค”" -> False
"๐Ÿ”นcode-golf๐Ÿ”น" -> False
"๐Ÿ˜ฎ ๐Ÿ˜ฅ ๐Ÿ˜จ ๐Ÿ˜ฉ ๐Ÿ˜ช" -> False
"I have no fancy emojis :(" -> False

"๐Ÿ˜Ž" -> True
"๐Ÿ˜Š๐Ÿ˜˜" -> True

For you poor souls who cannot see emojis, here is an image of the test cases.

  • 2
    \$\begingroup\$ Perhaps include a version (maybe an image) for those who can't see emojis? ;-) \$\endgroup\$ Dec 7 '16 at 0:10
  • \$\begingroup\$ @ETHproductions, do you suggest I link to a photo of the test cases or something else? \$\endgroup\$
    – Daniel
    Dec 7 '16 at 0:12
  • \$\begingroup\$ Well, there are emojis spread throughout the whole question, but I guess the only really important ones are in the test cases, so an image of just the test cases will work. \$\endgroup\$ Dec 7 '16 at 0:14
  • \$\begingroup\$ @ETHproductions, I added a link to a photo of the test cases \$\endgroup\$
    – Daniel
    Dec 7 '16 at 0:22
  • \$\begingroup\$ Can input be a numeric array of Unicode code points? Also, what range of characters/numbers can the input contain? \$\endgroup\$
    – Luis Mendo
    Dec 7 '16 at 0:24

Emojicode, 179 bytes

๐Ÿ‡a๐Ÿจ๐Ÿš๐Ÿš‚โžก๐Ÿš‚๐Ÿ”‚n๐Ÿกa๐Ÿ‡๐ŸŠ๐ŸŽ‰๐ŸŽ‰โ—€n 9728๐ŸŽŠโ–ถn 10175โ—€n 65024๐ŸŽ‰๐ŸŽ‰๐ŸŽŠโ–ถn 65039โ—€n 127744๐ŸŽŠโ–ถn 128591โ—€n 128640โ–ถn 128767๐Ÿ‡๐ŸŽ0๐Ÿ‰๐Ÿ‰๐ŸŽ1๐Ÿ‰

A callable that takes a list of integers representing the codepoints and returns 1 or 0.

Try it online!

Emojicode, 187 bytes

๐Ÿ‡a๐Ÿ”กโžก๐Ÿ‘Œ๐Ÿ”‚i๐Ÿกa๐Ÿ‡๐Ÿฆn๐Ÿš‚i๐ŸŠ๐ŸŽ‰๐ŸŽ‰โ—€n 9728๐ŸŽŠโ–ถn 10175โ—€n 65024๐ŸŽ‰๐ŸŽ‰๐ŸŽŠโ–ถn 65039โ—€n 127744๐ŸŽŠโ–ถn 128591โ—€n 128640โ–ถn 128767๐Ÿ‡๐ŸŽ๐Ÿ‘Ž๐Ÿ‰๐Ÿ‰๐ŸŽ๐Ÿ‘๐Ÿ‰

A callable that takes a string and returns a boolean.

Try it online!

Ungolfed and explained

๐Ÿ‘ด A callable that takes a ๐Ÿ”ก called input and returns a ๐Ÿ‘Œ
๐Ÿ‡ input ๐Ÿ”ก โžก ๐Ÿ‘Œ
 ๐Ÿ‘ด For each character in input
 ๐Ÿ”‚ character ๐Ÿก input ๐Ÿ‡
  ๐Ÿ‘ด Create a frozen called n containing the unicode codepoint of character
  ๐Ÿฆ n ๐Ÿš‚ character
  ๐Ÿ‘ด If the value is in one of specific ranges, return ๐Ÿ‘Ž (if the current character is not an emoji)
  ๐ŸŠ๐ŸŽ‰๐ŸŽ‰โ—€n 9728๐ŸŽŠโ–ถn 10175โ—€n 65024๐ŸŽ‰๐ŸŽ‰๐ŸŽŠโ–ถn 65039โ—€n 127744๐ŸŽŠโ–ถn 128591โ—€n 128640โ–ถn 128767๐Ÿ‡
   ๐ŸŽ ๐Ÿ‘Ž
 ๐Ÿ‘ด Since we're here, all characters are an emoji, so return ๐Ÿ‘

Try it online!


Ruby, 61 56+1 = 62 57 47 bytes

Uses the -n flag and takes input from STDIN. Prints 0 for truthy and nil for falsy.

-5 bytes because for some reason I initially thought the regex solution would not work???

-10 bytes from NieDzejkob for noticing a code point overlap that I missed :o


Try it online!

  • 1
    \$\begingroup\$ 47 bytes if you merge two ranges in the regex. \$\endgroup\$
    – NieDzejkob
    Dec 11 '17 at 19:40
  • 1
    \$\begingroup\$ That's 47 isn't it? \$\endgroup\$ Jan 22 '18 at 9:24
  • \$\begingroup\$ Yeah I forgot to update the score after getting the suggestion from @NieDzejkob \$\endgroup\$
    – Value Ink
    Jan 25 '18 at 9:25

JavaScript (V8), 39 bytes

Since the proposal for Unicode property escapes is now part of V8, this can also be addressed without manually specifying ranges. Granted, this comes years after the original question was asked, but I think it is an interesting addition none the less.


Try it online!


Python, 87 bytes

lambda x:re.match('^[๐Ÿ˜€-๐Ÿ™๐ŸŒ€-๐Ÿ—ฟ๐Ÿš€-๐Ÿ›ฟโ˜€-โžฟ๏ธ€-๏ธ€๏ธ]*$',x)and 1
import re

Try it online!

Returns 1 as truthy value and None as falsy value.

  • \$\begingroup\$ I "borrowed" your regex, hope you don't mind ;) \$\endgroup\$
    – hyper-neutrino
    Aug 15 '17 at 18:29
  • \$\begingroup\$ Since I told Value Ink about it, I'll tell you too - the first two groups in the regex can be merged because of adjacent codepoints: ๐ŸŒ€-๐Ÿ™ \$\endgroup\$
    – NieDzejkob
    Dec 11 '17 at 19:42
  • \$\begingroup\$ -12 bytes by using a better regex and using re.sub instead of re.match Try it online! \$\endgroup\$
    – Jakque
    Jun 28 '21 at 13:02

Proton, 54 bytes


Try it online!

-9 bytes (3 chars) thanks to NieDzejkob

"Borrowing" Uriel's regex :P This is shorter thanks to Proton's obscure features and regex literals


QuadR, 47 bytes


Try it online!


โ€ƒ''โ‰กโตโ€ƒan empty string identical to the result whenโ€ฆ

โ€ƒ[๐ŸŒ€-๐Ÿ™๐Ÿš€-๐Ÿ›ฟโ˜€-โžฟ๏ธ€-๏ธ€๏ธ]โ€ƒall emojis areโ€ฆ

โ€ƒโ€ƒreplaced with nothing



JavaScript, 83 61 bytes

-22 bytes thanks to @Shaggy




document.writeln(f("๐Ÿ”นcode-golf๐Ÿ”น")) //false
document.writeln(f("๐Ÿ˜ฎ ๐Ÿ˜ฅ ๐Ÿ˜จ ๐Ÿ˜ฉ ๐Ÿ˜ช")) //false
document.writeln(f("I have no fancy emojis :(")) //false
document.writeln(f("๐Ÿ˜Ž")) //true
document.writeln(f("๐Ÿ˜Š๐Ÿ˜˜")) //true

  • 1
    \$\begingroup\$ 61 bytes: s=>(s.match(/\ud83d[\ude00-\ude4f]/g)||"").length==s.length/2 \$\endgroup\$
    – Shaggy
    Aug 15 '17 at 15:46
  • \$\begingroup\$ Uh, how does this work? The regex doesn't specify the codepoints of any emoji... \$\endgroup\$
    – NieDzejkob
    Dec 11 '17 at 19:40
  • \$\begingroup\$ @NieDzejkob I believe JS uses UTF-16 for Unicode, so I guess these are the UTF-16 byte representations of those codepoints. The answer is incomplete though, it fails for ๐Ÿ›‚๐Ÿš€, โ™”โ˜บโ˜ , ๐Ÿ๐ŸŽ…๐ŸŒ etc., all of which should be truthy. It seems to check only for one range out of the six that OP mentions. \$\endgroup\$ Jul 10 '18 at 20:30

Your Answer

By clicking โ€œPost Your Answerโ€, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.