Template Literals & String.raw in JavaScript

From the JavaScript String Methods cheat sheet · String Formatting · verified Jul 2026

Template Literals & String.raw

Use template literals for string interpolation and String.raw for raw strings

javascript
// Template literals
const name = 'World'
const greeting = `Hello, ${name}!`  // 'Hello, World!'

// Multiline strings
const html = `
  <div>
    <h1>${name}</h1>
  </div>
`

// String.raw - no escape processing
const path = String.raw`C:\Users\Documents`  // Preserves backslashes
💡 Template literals are the modern way to build strings
⚡ String.raw preserves escape sequences literally
📌 Tagged templates enable DSLs and string processing
✅ Use String.raw for Windows paths and regex patterns

Continue with JavaScript String Methods

Save the full cheat sheet or work through every related task.

Back to the full JavaScript String Methods cheat sheet