Functions - Obsidian Help

Functions

aliases:
description: This page details the functions used in Obsidian Bases to manipulate data from properties in filters and formulas.
mobile: true
permalink: bases/functions
publish: true

Functions are used in Bases to manipulate data from properties in filters and formulas. See the bases syntax reference to learn more about how you can use functions.

Bases functions follow JavaScript behavior. For complete reference documentation, refer to MDN Web Docs.

Aside from Global functions, most functions depend on the type of value you want to modify:

Global

Global functions are used without a type.

escapeHTML()

escapeHTML(html: string): string

date()

date(date: string): date

duration()

duration(value: string): duration

file()

file(path: string | file | url): file

html()

html(html: string): html

if()

if(condition: any, trueResult: any, falseResult?: any): any

image()

image(path: string | file | url): image

icon()

icon(name: string): icon

link()

link(path: string | file, display?: value): Link

list()

list(element: any): List

max()

max(value1: number, value2: number...): number

min()

min(value1: number, value2: number...): number

now()

now(): date

number()

number(input: any): number

today()

today(): date

random()

random(): number

Any type

Functions you can use with any value. This includes strings (e.g. "hello"), numbers (e.g. 42), lists (e.g. [1,2,3]), objects, and more.

isTruthy()

any.isTruthy(): boolean

isType()

any.isType(type: string): boolean

toString()

any.toString(): string

Date type

Functions you can use with a date and time such as date("2025-05-27"). Date comparisons can be done using date arithmetic.

Fields

The following fields are available for dates:

Field Type Description
date.year number The year of the date
date.month number The month of the date (1–12)
date.day number The day of the month
date.hour number The hour (0–23)
date.minute number The minute (0–59)
date.second number The second (0–59)
date.millisecond number The millisecond (0–999)

date()

date.date(): date

format()

date.format(format: string): string

time()

date.time(): string

relative()

date.relative(): string

isEmpty()

date.isEmpty(): boolean

String type

Functions you can use with a sequence of characters such as "hello".

Fields

Field Type Description
string.length number The number of characters in the string

contains()

string.contains(value: string): boolean

containsAll()

string.containsAll(...values: string): boolean

containsAny()

string.containsAny(...values: string): boolean

endsWith()

string.endsWith(query: string): boolean

isEmpty()

string.isEmpty(): boolean

lower()

string.lower(): string

replace()

string.replace(pattern: string | Regexp, replacement: string): string

repeat()

string.repeat(count: number): string

reverse()

string.reverse(): string

slice()

string.slice(start: number, end?: number): string

split()

string.split(separator: string | Regexp, n?: number): list

startsWith()

string.startsWith(query: string): boolean

title()

string.title(): string

trim()

string.trim(): string

Number type

Functions you can use with numeric values such as 42, 3.14.

abs()

number.abs(): number

ceil()

number.ceil(): number

floor()

number.floor(): number

isEmpty()

number.isEmpty(): boolean

round()

number.round(digits: number): number

toFixed()

number.toFixed(precision: number): string

List type

Functions you can use with an ordered list of elements such as [1, 2, 3].

Fields

Field Type Description
list.length number The number of elements in the list

contains()

list.contains(value: any): boolean

containsAll()

list.containsAll(...values: any): boolean

containsAny()

list.containsAny(...values: any): boolean

filter()

list.filter(value: Boolean): list

flat()

list.flat(): list

isEmpty()

list.isEmpty(): boolean

join()

list.join(separator: string): string

map()

list.map(value: Any): list

reduce()

list.reduce(expression: Any, acc: Any): Any

reverse()

list.reverse(): list

slice()

list.slice(start: number, end?: number): list

sort()

list.sort(): list

unique()

list.unique(): list

Link type

Functions you can use on a link. Links can be created from a file (file.asLink()) or a path (link("path")).

asFile()

link.asFile(): file

linksTo()

link.linksTo(file): boolean

File type

Functions you can use with a file in the vault.

Fields

The following fields are available for files:

Field Type Description
file.name string The name of this file.
file.basename string The name of this file without the file extension.
file.path string The full path to this file, relative to the vault root.
file.folder string The full path to the parent folder.
file.ext string The file extension for this file.
file.size number The size of this file, in bytes.
file.properties object The note properties for this file.
file.tags list The tags for this file. Includes inline tags.
file.links list The internal links within this file.
file.ctime date Timestamp of when this file was created.
file.mtime date Timestamp of when this file was last modified.

asLink()

file.asLink(display?: string): Link

hasLink()

file.hasLink(otherFile: file | string): boolean

hasProperty()

file.hasProperty(name: string): boolean

hasTag()

file.hasTag(...values: string): boolean

inFolder()

file.inFolder(folder: string): boolean