# Module: tf.keras.preprocessing.text

<br />

Utilities for text input preprocessing.

> [!WARNING]
> **Deprecated:** [`tf.keras.preprocessing.text`](https://www.tensorflow.org/versions/r2.9/api_docs/python/tf/keras/preprocessing/text) APIs are not recommended for new code. Prefer [`tf.keras.utils.text_dataset_from_directory`](https://www.tensorflow.org/versions/r2.9/api_docs/python/tf/keras/utils/text_dataset_from_directory) and [`tf.keras.layers.TextVectorization`](https://www.tensorflow.org/versions/r2.9/api_docs/python/tf/keras/layers/TextVectorization) which provide a more efficient approach for preprocessing text input. For an introduction to these APIs, see the [text loading tutorial](https://www.tensorflow.org/tutorials/load_data/text) and [preprocessing layer guide](https://www.tensorflow.org/guide/keras/preprocessing_layers).

## Classes

[`class Tokenizer`](https://www.tensorflow.org/versions/r2.9/api_docs/python/tf/keras/preprocessing/text/Tokenizer): Text tokenization utility class.

## Functions

[`hashing_trick(...)`](https://www.tensorflow.org/versions/r2.9/api_docs/python/tf/keras/preprocessing/text/hashing_trick): Converts a text to a sequence of indexes in a fixed-size hashing space.

[`one_hot(...)`](https://www.tensorflow.org/versions/r2.9/api_docs/python/tf/keras/preprocessing/text/one_hot): One-hot encodes a text into a list of word indexes of size `n`.

[`text_to_word_sequence(...)`](https://www.tensorflow.org/versions/r2.9/api_docs/python/tf/keras/preprocessing/text/text_to_word_sequence): Converts a text to a sequence of words (or tokens).

[`tokenizer_from_json(...)`](https://www.tensorflow.org/versions/r2.9/api_docs/python/tf/keras/preprocessing/text/tokenizer_from_json): Parses a JSON tokenizer configuration and returns a tokenizer instance.