# How to return HTML from a Netlify function

> Learn how to return HTML from a Netlify function by setting the Content-type header to text/html instead of returning plain text in the response body.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2023-02-10 | Topics: [Services](https://flaviocopes.com/tags/services/) | Canonical: https://flaviocopes.com/how-to-return-html-from-a-netlify-function/

Instead of 

```javascript

return {
  statusCode: 200,
  body: 'Test',
}
```

Use

```javascript
return {
  statusCode: 200,
  headers: {
    'Content-type': 'text/html; charset=UTF-8',
  },
  body: '<body style="background-color: black;"><h2 style="color: white; padding-top:200px; text-align: center; font-family: system-ui">Test</h2></body>',
}
```
