Obsidian - Inline Scripts
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.
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?
What makes the “folder randomizer” approach more maintainable than hard-coded tables?
What does the script need from notes in the target folder for table generation to work?
How are triggers and parameters handled in Inline Scripts shortcuts?
How do folder and subfolder syntaxes affect which notes get pulled?
Why does the transcript stress the order of imported libraries and script prerequisites?
Review Questions
- When would you prefer a folder-based randomizer over a hard-coded markdown table in Inline Scripts?
- What frontmatter fields must exist in notes for a generated table (like spells or potions) to populate correctly?
- How can Inline Scripts preserve dice-roll history inside a note compared with an interactive dice roller plugin?
Key Points
- 1
Inline Scripts can generate random tables and linked content directly inside Obsidian notes using JavaScript-triggered output.
- 2
Folder-based randomizers select random notes from a folder/subfolder and populate markdown tables using frontmatter fields.
- 3
Adding new notes to the target folder automatically expands the generator’s results, avoiding hard-coded table maintenance.
- 4
Inline Scripts can persist dice outcomes in the note, unlike interactive dice rollers that re-roll on each note reopen.
- 5
Installation requires installing the Inline Scripts community plugin and importing the full library so dependent libraries (like notepic) are available.
- 6
Shortcut triggers use configurable prefix/suffix characters, and parameter prompts can be added with placeholders like “???”.
- 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.