---
title: make_valid_utf8
description: "make\\_valid\\_utf8 function in PySpark: Returns a new string in which all invalid UTF-8 byte sequences, if any, are replaced by the Unicode replacement character (U+FFFD)."
canonical_url: https://docs.databricks.com/aws/en/pyspark/reference/functions/make_valid_utf8
---

# make\_valid\_utf8

Returns a new string in which all invalid UTF-8 byte sequences, if any, are replaced by the Unicode replacement character (U+FFFD).

For the corresponding Databricks SQL function, see [`make_valid_utf8` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/make_valid_utf8.md).

## Syntax

```python
from pyspark.sql import functions as dbf

dbf.make_valid_utf8(str=<str>)
```

## Parameters

| Parameter | Type                          | Description                                                   |
| --------- | ----------------------------- | ------------------------------------------------------------- |
| `str`     | `pyspark.sql.Column` or `str` | A column of strings, each representing a UTF-8 byte sequence. |

## Returns

`pyspark.sql.Column`: the valid UTF-8 version of the given input string.

## Examples

```python
from pyspark.sql import functions as dbf
spark.range(1).select(dbf.make_valid_utf8(dbf.lit("SparkSQL"))).show()
```
