June 22, 2026 · by Meegrow Labs

Serving HTML: Send a Real Web Page From Your Server

Your server can send data. But here’s the thing: people don’t read raw data. They open a browser and expect to see a page. So far your server has been handing back JSON, which is great for programs but looks like gibberish to a normal visitor.

This is where serving HTML changes everything. Instead of data, you send a real page, and the browser turns it into something a human can actually see.

Serving HTML means your server sends back HTML code instead of plain data, and the browser renders that code into a real, visible web page on screen.

What does serving HTML actually mean?

Think of a poster. You design it, print it, then stick it on a wall for everyone to see. Serving HTML is exactly that. Your server prints the page, and the browser puts it on the wall for the visitor.

The quick way to remember the difference: JSON is for programs to read, and HTML is a page for people to see. Both travel the same way over the internet, but they have very different jobs.

  • JSON — structured data, meant for one program to read and use.
  • HTML — the language of web pages, meant for the browser to display.

When you visited a JSON route earlier in the free Zero to AI Hero course, your browser showed plain text. Send HTML instead, and the same browser draws headings, buttons, and layout.

How do I serve HTML in my server?

You already know res.send from sending data. The trick is simple: pass it HTML instead. Here is the smallest possible example.

app.get('/', (req, res) => {
  res.send('<h1>Hi</h1>')
})

Let’s read that line by line. res.send means “send the page back to the browser.” The <h1>Hi</h1> inside it is the HTML itself — an h1 heading tag with the text “Hi.”

That is the whole idea. You hand the browser HTML, and the browser does the rest. It reads the <h1> tag and renders it as a big, bold heading.

Why is serving HTML such a big step?

Because you type the address, hit enter, and there it is — your first self-hosted page. Not a JSON blob, not a test message, but an actual web page coming from a server you built yourself.

Up to now your server was talking to programs. Now it is talking to people. That is the moment your project starts to feel like a real website instead of a backend experiment.

How do I try it right now?

You don’t need anything new. Just three steps with the server you already have:

  • Add the route above that returns your HTML.
  • Run your server the same way you did in the learn step by step lessons.
  • Open localhost in your browser at your server’s address.

Your page appears on screen. Change the text inside the <h1>, refresh, and watch it update. That fast loop — edit, refresh, see — is how every web developer works.

JSON or HTML — which should I send?

It depends on who is on the other end. If another program is calling your server, send JSON so it can read the data cleanly. If a person is opening a browser, send HTML so they see a proper page.

Most real apps do both: HTML pages for humans, and JSON routes for the parts of the app that talk to each other. You met data routes when serving JSON; now you can serve pages too, and you choose the right one per route.

Key takeaways

  • Serving HTML sends a real web page from your server; the browser renders it into something people can see.
  • JSON is for programs to read; HTML is a page for people to view.
  • Use res.send('<h1>Hi</h1>') to return HTML from a route.
  • res.send sends the page; the tags inside are the HTML the browser renders.
  • Run your server, open localhost in a browser, and your page appears — your first self-hosted page.

Next up: stopping and restarting your server cleanly, so you can edit your page and reload without surprises.


🚀 Take the full free course: Zero to AI Hero — learn to build with AI from scratch. New lessons daily, in Hindi & English.

Meegrow Labs

We help India go from zero to AI hero — learn to use & build with AI from scratch, in Hindi & English. Start the free course →

Want to actually learn this?

151 free 2-minute lessons — from "what's a file?" to building with AI.

▶ Start the free course