• Skip to main content
  • Skip to search
  • Skip to select language
MDN Web Docs
  • References
    • Overview / Web Technology

      Web technology reference for developers

    • HTML

      Structure of content on the web

    • CSS

      Code used to describe document style

    • JavaScript

      General-purpose scripting language

    • HTTP

      Protocol for transmitting web resources

    • Web APIs

      Interfaces for building web applications

    • Web Extensions

      Developing extensions for web browsers

    • Web Technology

      Web technology reference for developers

  • Guides
    • Overview / MDN Learning Area

      Learn web development

    • MDN Learning Area

      Learn web development

    • HTML

      Learn to structure web content with HTML

    • CSS

      Learn to style content using CSS

    • JavaScript

      Learn to run scripts in the browser

    • Accessibility

      Learn to make the web accessible to all

  • Plus
    • Overview

      A customized MDN experience

    • AI Help

      Get real-time assistance and support

    • Updates

      All browser compatibility updates at a glance

    • Documentation

      Learn how to use MDN Plus

    • FAQ

      Frequently asked questions about MDN Plus

  • Curriculum
  • Blog
    • Playground

      Write, test and share your code

    • HTTP Observatory

      Scan a website for free

    • AI Help

      Get real-time assistance and support

  • Log in
  • Sign up for free
  1. References
  2. Web APIs
  3. TextEncoder
  4. TextEncoder()
    • Français
    • 日本語
    • 中文 (简体)

In this article

  • Syntax
  • Specifications
  • Browser compatibility
  • See also
  1. Encoding API
  2. TextEncoder
  3. Constructor
    1. TextEncoder()
  4. Instance properties
    1. encoding
  5. Instance methods
    1. encode()
    2. encodeInto()
  6. Related pages for Encoding API
    1. TextDecoder
    2. TextDecoderStream
    3. TextEncoderStream

In this article

  • Syntax
  • Specifications
  • Browser compatibility
  • See also

TextEncoder: TextEncoder() constructor

Note: This feature is available in Web Workers.

The TextEncoder() constructor returns a newly created TextEncoder object that will generate a byte stream with UTF-8 encoding.

Syntax

js
new TextEncoder()

Parameters

None.

Specifications

Specification
Encoding Standard
# ref-for-dom-textencoder①

Browser compatibility

BCD tables only load in the browser

See also

  • The TextEncoder interface it belongs to.

Help improve MDN

Learn how to contribute.

This page was last modified on Sep 25, 2024 by MDN contributors.

View this page on GitHub • Report a problem with this content
MDN logo

Your blueprint for a better internet.

  • MDN on Mastodon
  • MDN on X (formerly Twitter)
  • MDN on GitHub
  • MDN Blog RSS Feed

MDN

  • About
  • Blog
  • Careers
  • Advertise with us

Support

  • Product help
  • Report an issue

Our communities

  • MDN Community
  • MDN Forum
  • MDN Chat

Developers

  • Web Technologies
  • Learn Web Development
  • MDN Plus
  • Hacks Blog
Mozilla logo
  • Website Privacy Notice
  • Cookies
  • Legal
  • Community Participation Guidelines

Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2024 by individual mozilla.org contributors. Content available under a Creative Commons license.