Get AI summaries of any video or article — Sign up free
Obsidian - Inline Scripts thumbnail

Obsidian - Inline Scripts

Josh Plunkett·
5 min read

Based on Josh Plunkett's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.

TL;DR

Inline Scripts can generate random tables and linked content directly inside Obsidian notes using JavaScript-triggered output.

Briefing

Inline Scripts for Obsidian lets users run JavaScript inside a Vault and have the results render directly as formatted text—often as ready-to-use tables or linked records—at the moment they type a trigger. That turns “random tables” from static, pre-made assets into on-demand generators that can pull from notes, roll dice, and even store roll history inside the note for later reference.

A key example shows how a single inline command can generate a random “blacksmith” inventory table. Instead of hunting down a separate rollable table, the user types a trigger (using a prefix/suffix like “;; … : :”) and immediately gets a table of items. The results change on each run, but the output is embedded right where it’s needed—useful for game prep and for documenting what happened during play.

The workflow becomes more powerful when Inline Scripts pull data from existing notes. A hard-coded table can work, but it’s labor-intensive to maintain. The more scalable approach uses a “folder randomizer” pattern: the script selects random notes from a chosen folder (or subfolder), then reads their frontmatter fields (like cost, rarity, level, or other metadata) to populate table columns. That means adding new notes to a folder automatically expands what the generator can produce—no manual table edits required.

The transcript also highlights a practical advantage over interactive dice rollers. Traditional dice plugins typically roll again every time the note is reopened, leaving no persistent record. Inline Scripts can write the roll result into the note itself, so a later “journal” entry can show what the players rolled (for example, a d20 check) and whether it succeeded.

Installation is done through Obsidian’s Community Plugins: search for “Inline Scripts,” install and enable it, then import the “full library” so the needed helper libraries (including a “notepic” library) are available. The setup includes configurable shortcut prefixes/suffixes and a library of prebuilt buttons. From there, users can create custom shortcuts that prompt for parameters (using question-mark placeholders), such as asking how many spells or potions to generate.

The most concrete implementation details focus on how the folder-based scripts are structured. The script defines a trigger name (e.g., “get my folder” or “get spell book”), declares a result-building loop, and constructs markdown table rows by concatenating strings and inserting newlines. It also relies on consistent frontmatter: every note in the target folder must include the metadata fields the script expects, or the output will show undefined values or errors. The transcript stresses that the number of requested random results can’t exceed the number of eligible notes.

By the end, the appeal is clear: Inline Scripts turns Obsidian into a lightweight RPG content engine. With folder-driven random tables, users can generate shop inventories, spell lists, mundane items, and other structured content on demand—then link each generated item back to its source note for quick reference during play.

Cornell Notes

Inline Scripts for Obsidian runs JavaScript inside a Vault and inserts the output directly into notes. The standout capability is generating random tables and linked results on demand—often by selecting random notes from a folder and reading their frontmatter to fill table columns. This makes “rollable tables” dynamic: adding new notes to a folder automatically expands what the generator can produce. Inline Scripts can also persist dice outcomes inside the note, unlike interactive rollers that change every time the note opens. The setup involves installing the Inline Scripts community plugin, importing the full library, and creating shortcut triggers (with optional user prompts) that call scripts like “get my folder” or “get spell book.”

How does Inline Scripts differ from using separate rollable tables or interactive dice rollers?

Inline Scripts embeds generated results directly into the note at the moment a trigger is typed (or a button is clicked). That removes the need to locate a separate rollable table and manually roll against it. For dice specifically, Inline Scripts can write the roll result into the note so it stays as a record; interactive dice rollers typically re-roll when the note is reopened, producing different results each time and leaving no stable history.

What makes the “folder randomizer” approach more maintainable than hard-coded tables?

Hard-coded tables require one line per possible outcome, so expanding the table means editing the script. The folder randomizer instead pulls random notes from a specified folder or subfolder and uses frontmatter fields (like cost, rarity, level, school, etc.) to populate table columns. As long as new notes include the required metadata, the generator automatically includes them—no script rewrite needed.

What does the script need from notes in the target folder for table generation to work?

Every note selected by the script must contain the frontmatter fields the script expects. The transcript notes that missing metadata leads to undefined values or errors. It also emphasizes that the requested number of random results can’t exceed the number of eligible notes in the folder/subfolder being queried.

How are triggers and parameters handled in Inline Scripts shortcuts?

Shortcuts use configurable prefix/suffix characters (the transcript uses a “;; … : :” style). A shortcut name (like “get spell book”) is the trigger text. Parameters can be collected via placeholders like “???”, which prompt the user for input (e.g., how many spells or potions to generate). The script then uses that parameter to control how many random notes to select.

How do folder and subfolder syntaxes affect which notes get pulled?

The transcript distinguishes parent-folder syntax from subfolder syntax. Parent-folder selection uses a bracketed folder name at the top level (e.g., “my folder”). Subfolder selection uses a path-like bracket syntax that includes the parent and subfolder (slashes/backslashes are part of the required syntax). Choosing the wrong level changes the candidate note set and can break requests (like asking for more items than exist in that specific folder scope).

Why does the transcript stress the order of imported libraries and script prerequisites?

Inline Scripts can depend on libraries being loaded before scripts run. The transcript warns that the order matters during import/troubleshooting—some helper code must exist before other scripts that reference it will work correctly.

Review Questions

  1. When would you prefer a folder-based randomizer over a hard-coded markdown table in Inline Scripts?
  2. What frontmatter fields must exist in notes for a generated table (like spells or potions) to populate correctly?
  3. How can Inline Scripts preserve dice-roll history inside a note compared with an interactive dice roller plugin?

Key Points

  1. 1

    Inline Scripts can generate random tables and linked content directly inside Obsidian notes using JavaScript-triggered output.

  2. 2

    Folder-based randomizers select random notes from a folder/subfolder and populate markdown tables using frontmatter fields.

  3. 3

    Adding new notes to the target folder automatically expands the generator’s results, avoiding hard-coded table maintenance.

  4. 4

    Inline Scripts can persist dice outcomes in the note, unlike interactive dice rollers that re-roll on each note reopen.

  5. 5

    Installation requires installing the Inline Scripts community plugin and importing the full library so dependent libraries (like notepic) are available.

  6. 6

    Shortcut triggers use configurable prefix/suffix characters, and parameter prompts can be added with placeholders like “???”.

  7. 7

    Scripts rely on consistent metadata and the number of requested results can’t exceed the number of eligible notes in the selected folder scope.

Highlights

Typing a trigger like “;; table blacksmith : :” can instantly generate a random inventory table embedded in the note.
A folder randomizer pattern turns static tables into dynamic generators by pulling random notes and reading their frontmatter.
Inline Scripts can store dice results inside the note, creating a durable play log rather than re-rolling every time.
Shortcut buttons can prompt for parameters (e.g., how many spells/potions) and then generate the requested number of linked entries.
The folder/subfolder syntax determines which notes are eligible; requesting more items than exist in that scope fails or returns incomplete data.

Topics