> This page location: String Functions > MD5
> Full Neon documentation index: https://neon.com/docs/llms.txt

# PostgreSQL MD5() Function

**Info:** The MD5() function works the same across any PostgreSQL deployment, so what you learn here applies whether you're running Postgres on your laptop, a managed service, or a cloud platform. If you're an enterprise looking for managed Postgres built for the AI era, [Lakebase](https://www.databricks.com/product/lakebase) delivers the performance, security, and native Lakehouse integration you need. If you're a developer or startup who needs to ship and scale fast, [Neon](https://neon.com) gives you the best Postgres platform for moving quickly.

The PostgreSQL `MD5()` function calculates the [MD5](https://en.wikipedia.org/wiki/MD5) hash of a string and returns the result in hexadecimal.

## Syntax

The following illustrates the syntax of the `MD5()` function:

```sql
MD5(string)
```

## Arguments

The `MD5()` function accepts one argument.

**1) `string`**

The `string` argument is the string of which the MD5 hash is calculated.

## Return value

The `MD5()` function returns a string in [`TEXT`](../postgresql-tutorial/postgresql-char-varchar-text) data type.

## Examples

The following example shows how to use the `MD5()` function to return the MD5 hash of the message `'PostgreSQL MD5'`:

```sql
SELECT MD5('PostgreSQL MD5');
```

The result is:

```
        md5
----------------------------------
 f78fdb18bf39b23d42313edfaf7e0a44
(1 row)
```

In this tutorial, you have learned how to use the PostgreSQL `MD5()` function to calculate the MD5 hash of a string.

---

## Related docs (String Functions)

- [ASCII](https://neon.com/postgresql/string-functions/ascii)
- [CHR](https://neon.com/postgresql/string-functions/chr)
- [CONCAT](https://neon.com/postgresql/string-functions/concat-function)
- [CONCAT_WS](https://neon.com/postgresql/string-functions/concat_ws)
- [FORMAT](https://neon.com/postgresql/string-functions/format)
- [INITCAP](https://neon.com/postgresql/string-functions/initcap)
- [LEFT](https://neon.com/postgresql/string-functions/left)
- [LENGTH](https://neon.com/postgresql/string-functions/length-function)
- [LOWER](https://neon.com/postgresql/string-functions/lower)
- [LPAD](https://neon.com/postgresql/string-functions/lpad)
- [LTRIM](https://neon.com/postgresql/string-functions/ltrim)
- [POSITION](https://neon.com/postgresql/string-functions/position)
- [REGEXP_MATCHES](https://neon.com/postgresql/string-functions/regexp_matches)
- [REGEXP_REPLACE](https://neon.com/postgresql/string-functions/regexp_replace)
- [REPEAT](https://neon.com/postgresql/string-functions/repeat)
- [REVERSE](https://neon.com/postgresql/string-functions/reverse)
- [REPLACE](https://neon.com/postgresql/string-functions/replace)
- [RIGHT](https://neon.com/postgresql/string-functions/right)
- [RPAD](https://neon.com/postgresql/string-functions/rpad)
- [RTRIM](https://neon.com/postgresql/string-functions/rtrim)
- [SPLIT_PART](https://neon.com/postgresql/string-functions/split_part)
- [SUBSTRING](https://neon.com/postgresql/string-functions/substring)
- [TO_CHAR](https://neon.com/postgresql/string-functions/to_char)
- [TO_NUMBER](https://neon.com/postgresql/string-functions/to_number)
- [TRANSLATE](https://neon.com/postgresql/string-functions/translate)
- [TRIM](https://neon.com/postgresql/string-functions/trim-function)
- [UPPER](https://neon.com/postgresql/string-functions/upper)
