<% let message = 'Hello, World!' %> <%= message %>
Write, Run & Share EJS templates online using OneCompiler’s EJS online compiler for free. It’s a minimal yet powerful online playground for rendering dynamic HTML using Embedded JavaScript (EJS). Getting started with OneCompiler’s EJS editor is quick and easy. You get a sample boilerplate EJS code with every new session.
EJS (Embedded JavaScript templating) is a simple templating language that lets you generate HTML markup with plain JavaScript. It is commonly used in Node.js applications, especially with Express, to render views on the server side.
EJS syntax allows embedding JavaScript logic directly within HTML using <% %>
delimiters.
The following is a sample EJS template that displays a personalized greeting:
<%
let message = 'Hello, World!'
%>
<%= message %>
<%= %>
— Outputs the value into the template (escaped)<%- %>
— Outputs unescaped HTML<p>Hello, <%= user.name %>!</p>
<%- include('footer') %>
<% %>
— Executes JavaScript logic without output<% if (user.isLoggedIn) { %>
<p>Welcome, <%= user.name %>!</p>
<% } else { %>
<p>Please log in.</p>
<% } %>
<ul>
<% items.forEach(function(item) { %>
<li><%= item %></li>
<% }); %>
</ul>
<%- include('header') %>
<main>
Content goes here
</main>
<%- include('footer') %>
This guide provides a quick reference to EJS templating syntax and usage. Start writing and rendering EJS code with OneCompiler’s EJS online compiler today!