# What Programming Languages Does Macro Support? Full List and Developer Guide

> Discover the 17 programming languages Macro supports, including JavaScript, Python, Rust, Java, Swift, C, C++, and SQL. Enhance your development workflow with Macro's lexical-core editor.

- Repository: [Macro/macro](https://github.com/macro-inc/macro)
- Tags: getting-started
- Published: 2026-08-14

---

**Macro supports 17 programming languages including JavaScript, TypeScript, Python, Rust, Java, Swift, C, C++, SQL, Bash, and others, with alias recognition and file extension detection built into its lexical-core editor.**

Macro's code editor provides first-class syntax highlighting for a curated set of languages. This capability is centralized in the lexical-core package, making it easy for developers to verify language support, normalize aliases, and detect languages from file extensions. Understanding this system helps you work more effectively with code blocks in Macro documents.

## Complete List of Supported Programming Languages

The authoritative source for Macro's language support is [`packages/lexical-core/utils/languageSupport.ts`](https://github.com/macro-inc/macro/blob/main/packages/lexical-core/utils/languageSupport.ts). This module defines the `SupportedLanguages` constant and `LanguageDefinitions` map that power syntax highlighting across the platform.

### Core Languages and Recognized Aliases

| Language | Aliases | File Extensions |
|----------|---------|-----------------|
| **Plain Text** | `text` | `.txt` |
| **JavaScript** | `js`, `jsx`, `java script` | `.js`, `.jsx` |
| **TypeScript** | `ts`, `tsx`, `type script` | `.ts`, `.tsx` |
| **JSON** | — | `.json` |
| **Python** | `py` | `.py` |
| **Rust** | `rs` | `.rs` |
| **Java** | — | `.java` |
| **Swift** | — | `.swift` |
| **C** | — | `.c`, `.h` |
| **C++** | `c++` | `.cpp`, `.cc`, `.cxx`, `.hpp` |
| **CSS** | — | `.css` |
| **HTML** | — | `.html`, `.htm` |
| **Markdown** | `md` | `.md`, `.markdown` |
| **PowerShell** | `ps1`, `ps` | `.ps1`, `.psm1`, `.psd1` |
| **SQL** | — | `.sql` |
| **Bash** | `sh`, `zsh`, `fish` | `.sh`, `.bash`, `.zsh` |
| **SVG** | `xml` | `.svg` |

## Language Support Utility Functions

The [`languageSupport.ts`](https://github.com/macro-inc/macro/blob/main/languageSupport.ts) module exposes four primary helper functions for working with supported languages programmatically.

### Checking Language Support

Use `isSupportedLanguage()` to verify if a string represents a supported language or alias:

```typescript
import { isSupportedLanguage } from '@macro/lexical-core/utils/languageSupport';

const lang = 'js';
if (isSupportedLanguage(lang)) {
  console.log(`${lang} is a supported language`); // ✓ Matches 'javascript'
}

```

### Normalizing Language Names

The `normalizedLanguage()` function converts any alias to its canonical form, falling back to `plaintext` for unrecognized inputs:

```typescript
import { normalizedLanguage } from '@macro/lexical-core/utils/languageSupport';

normalizedLanguage('tsx');      // ⇒ 'typescript'
normalizedLanguage('java script'); // ⇒ 'javascript'
normalizedLanguage('unknown');  // ⇒ 'plaintext' (fallback)

```

### Detecting Languages from File Extensions

Pass a file extension (with or without leading dot) to `getSupportedLanguageFromFileExtension()`:

```typescript
import { getSupportedLanguageFromFileExtension } from '@macro/lexical-core/utils/languageSupport';

getSupportedLanguageFromFileExtension('.py');   // ⇒ 'python'
getSupportedLanguageFromFileExtension('rs');    // ⇒ 'rust'
getSupportedLanguageFromFileExtension('.xyz');  // ⇒ 'plaintext' (fallback)

```

### Building Language Selectors

For UI components, `getSelectableLanguages()` returns metadata objects with display labels and highlight capabilities:

```typescript
import { getSelectableLanguages } from '@macro/lexical-core/utils/languageSupport';

const options = getSelectableLanguages();
// Array of: { label: string, show: boolean, aliases?: string[], highlightsEnabled?: boolean }

```

## Source Code Architecture

Macro's language support is implemented across three key files that ensure consistent behavior between core editor logic and web UI components.

### Core Definition: [`packages/lexical-core/utils/languageSupport.ts`](https://github.com/macro-inc/macro/blob/main/packages/lexical-core/utils/languageSupport.ts)

This is the **source of truth** for all supported languages. It exports:
- `SupportedLanguages` — the constant array of language definitions
- `LanguageDefinitions` — the mapping of canonical names to aliases and metadata
- All four utility functions described above

### Markdown Integration: [`packages/lexical-core/utils/markdown-mentions.ts`](https://github.com/macro-inc/macro/blob/main/packages/lexical-core/utils/markdown-mentions.ts)

This file demonstrates how language detection integrates with markdown code block handling. When Macro parses fenced code blocks (```language), it uses the same normalization logic to apply correct syntax highlighting.

### Web UI Mirror: `apps/web/src/features/block-code/util/languageSupport.ts`

The web-based editor maintains an identical language list for UI consistency. This mirroring ensures that language selectors in the browser match the core editor's capabilities exactly.

## Practical Implementation Examples

### Validating User Input for Code Blocks

```typescript
import {
  isSupportedLanguage,
  normalizedLanguage
} from '@macro/lexical-core/utils/languageSupport';

function setCodeBlockLanguage(userInput: string): string {
  // Accept aliases but store canonical name
  if (isSupportedLanguage(userInput)) {
    return normalizedLanguage(userInput);
  }
  
  // Graceful degradation
  console.warn(`Unsupported language "${userInput}", defaulting to plaintext`);
  return 'plaintext';
}

setCodeBlockLanguage('py');      // ⇒ 'python'
setCodeBlockLanguage('sh');      // ⇒ 'bash'
setCodeBlockLanguage('brainfck'); // ⇒ 'plaintext' (with warning)

```

### Auto-Detecting Language from Filenames

```typescript
import { getSupportedLanguageFromFileExtension } from '@macro/lexical-core/utils/languageSupport';

function detectLanguageFromPath(filePath: string): string {
  const ext = filePath.slice(filePath.lastIndexOf('.'));
  return getSupportedLanguageFromFileExtension(ext);
}

detectLanguageFromPath('src/utils/helpers.ts'); // ⇒ 'typescript'
detectLanguageFromPath('script.ps1');           // ⇒ 'powershell'
detectLanguageFromPath('Dockerfile');           // ⇒ 'plaintext' (no extension match)

```

## Adding New Programming Languages to Macro

Currently, Macro uses a **hardcoded, curated list** rather than dynamic language loading. To extend support:

1. Modify [`packages/lexical-core/utils/languageSupport.ts`](https://github.com/macro-inc/macro/blob/main/packages/lexical-core/utils/languageSupport.ts) to add entries to `SupportedLanguages`
2. Include canonical name, display label, file extensions, and known aliases
3. Update [`apps/web/src/features/block-code/util/languageSupport.ts`](https://github.com/macro-inc/macro/blob/main/apps/web/src/features/block-code/util/languageSupport.ts) to match
4. Ensure corresponding highlight.js or Prism grammar is available in the editor

The maintainers prioritize languages based on usage analytics and community demand.

## Summary

- **Macro supports 17 programming languages** with explicit alias handling for common variations
- **Language detection is centralized** in [`packages/lexical-core/utils/languageSupport.ts`](https://github.com/macro-inc/macro/blob/main/packages/lexical-core/utils/languageSupport.ts)
- **Four utility functions** provide complete language management: `isSupportedLanguage()`, `normalizedLanguage()`, `getSupportedLanguageFromFileExtension()`, and `getSelectableLanguages()`
- **Automatic fallback to `plaintext`** prevents breaking errors on unrecognized inputs
- **Web UI maintains parity** with core definitions through a mirrored implementation

## Frequently Asked Questions

### Does Macro support every programming language?

No. Macro intentionally maintains a curated list of 17 languages covering the most common use cases. According to the macro-inc/macro source code, unsupported languages gracefully fall back to `plaintext` rendering without syntax highlighting.

### Can I use abbreviations like "js" or "py" when specifying languages?

Yes. The `normalizedLanguage()` function in [`languageSupport.ts`](https://github.com/macro-inc/macro/blob/main/languageSupport.ts) recognizes multiple aliases per language. For example, `js`, `jsx`, and `java script` all normalize to `javascript`, while `py` maps to `python`.

### How does Macro detect the correct language for a file?

Macro uses `getSupportedLanguageFromFileExtension()`, which strips the leading dot and matches against registered extensions for each supported language. If no match exists, it returns `plaintext` to ensure the file remains readable.

### Is the language list the same across web and desktop versions of Macro?

Yes. The web implementation at [`apps/web/src/features/block-code/util/languageSupport.ts`](https://github.com/macro-inc/macro/blob/main/apps/web/src/features/block-code/util/languageSupport.ts) mirrors the core lexical-core definitions, ensuring consistent language support across all Macro platforms.