JavaScript Ends with

endsWith() returns true if the string finishes with the given characters, false otherwise. It is the mirror of startsWith() and is handy for testing file extensions or suffixes. Case-sensitive.

Syntax

str.endsWith(search)

Examples

Input Arguments Output
"image.png" ".png" true

When to use it

  • Validate file extensions.
  • Detect trailing markers or units.

Try it live

Type your input and see Ends with transform it instantly.

Ends with()

Type above to see the result…

Want to go further? Chain Ends with with other functions, pipe one output into the next and watch your data transform in the visual Playground.

Related functions

© 2026 Heifara Buval