Title: esc_textarea
Published: April 25, 2014
Last modified: February 24, 2026

---

# esc_textarea( string $text ): string

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/esc_textarea/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/esc_textarea/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/esc_textarea/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/esc_textarea/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/esc_textarea/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/esc_textarea/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/esc_textarea/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/esc_textarea/?output_format=md#wp--skip-link--target)

Escaping for textarea values.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/esc_textarea/?output_format=md#parameters)󠁿

 `$text`stringrequired

## 󠀁[Return](https://developer.wordpress.org/reference/functions/esc_textarea/?output_format=md#return)󠁿

 string

## 󠀁[Source](https://developer.wordpress.org/reference/functions/esc_textarea/?output_format=md#source)󠁿

    ```php
    function esc_textarea( $text ) {
    	$safe_text = htmlspecialchars( $text, ENT_QUOTES, get_option( 'blog_charset' ) );
    	/**
    	 * Filters a string cleaned and escaped for output in a textarea element.
    	 *
    	 * @since 3.1.0
    	 *
    	 * @param string $safe_text The text after it has been escaped.
    	 * @param string $text      The text prior to being escaped.
    	 */
    	return apply_filters( 'esc_textarea', $safe_text, $text );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/formatting.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/formatting.php#L4739)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/formatting.php#L4739-L4750)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/esc_textarea/?output_format=md#hooks)󠁿

 [apply_filters( ‘esc_textarea’, string $safe_text, string $text )](https://developer.wordpress.org/reference/hooks/esc_textarea/)

Filters a string cleaned and escaped for output in a textarea element.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/esc_textarea/?output_format=md#related)󠁿

| Uses | Description | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  |

| Used by | Description | 
| [WP_Widget_Block::form()](https://developer.wordpress.org/reference/classes/wp_widget_block/form/)`wp-includes/widgets/class-wp-widget-block.php` |

Outputs the Block widget settings form.

  | 
| [WP_Widget_Custom_HTML::form()](https://developer.wordpress.org/reference/classes/wp_widget_custom_html/form/)`wp-includes/widgets/class-wp-widget-custom-html.php` |

Outputs the Custom HTML widget settings form.

  | 
| [print_embed_sharing_dialog()](https://developer.wordpress.org/reference/functions/print_embed_sharing_dialog/)`wp-includes/embed.php` |

Prints the necessary markup for the embed sharing dialog.

  | 
| [network_step2()](https://developer.wordpress.org/reference/functions/network_step2/)`wp-admin/includes/network.php` |

Prints step 2 for Network installation process.

  | 
| [get_inline_data()](https://developer.wordpress.org/reference/functions/get_inline_data/)`wp-admin/includes/template.php` |

Adds hidden fields with the data for use in the inline editor for posts and pages.

  | 
| [_list_meta_row()](https://developer.wordpress.org/reference/functions/_list_meta_row/)`wp-admin/includes/template.php` |

Outputs a single row of public meta data in the Custom Fields meta box.

  | 
| [WP_Comments_List_Table::column_comment()](https://developer.wordpress.org/reference/classes/wp_comments_list_table/column_comment/)`wp-admin/includes/class-wp-comments-list-table.php` |  | 
| [format_to_edit()](https://developer.wordpress.org/reference/functions/format_to_edit/)`wp-includes/formatting.php` |

Acts on text which is about to be edited.

  | 
| [WP_Widget_Text::form()](https://developer.wordpress.org/reference/classes/wp_widget_text/form/)`wp-includes/widgets/class-wp-widget-text.php` |

Outputs the Text widget settings form.

  | 
| [WP_Customize_Control::render_content()](https://developer.wordpress.org/reference/classes/wp_customize_control/render_content/)`wp-includes/class-wp-customize-control.php` |

Renders the control’s content.

  |

[Show 5 more](https://developer.wordpress.org/reference/functions/esc_textarea/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/esc_textarea/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/esc_textarea/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.1.0](https://developer.wordpress.org/reference/since/3.1.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/esc_textarea/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/esc_textarea/?output_format=md#comment-content-2474)
 2.   [Michael Nelson](https://profiles.wordpress.org/mnelson4/)  [  8 years ago  ](https://developer.wordpress.org/reference/functions/esc_textarea/#comment-2474)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fesc_textarea%2F%23comment-2474)
    Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fesc_textarea%2F%23comment-2474)
 4. It seems this function may have wider applicability than its name indicates, please
    see [https://developer.wordpress.org/reference/functions/esc_attr/#comment-2473](https://developer.wordpress.org/reference/functions/esc_attr/#comment-2473)
 5.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fesc_textarea%2F%3Freplytocom%3D2474%23feedback-editor-2474)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fesc_textarea%2F)
before being able to contribute a note or feedback.