Overview of all frontmatter fields used in vault

Hi guys, I want to clean up (as in harmonize) the yaml frontmatter (metadata) fields of my vault. I’ve been using Obsidian for some months now and have been constantly adjusting the metadata fields which have become a real mess over time.

How can I get an overview of all metadata fields of all my files in the vault?

For example …

… from a frontmatter like this I would like to list the fields “title”, “date”, “author”, “source” and “link”.

title: {{title}}
date: {{date:YYYY-MM-DD}}

… from a frontmatter like this I would like to list the fields “learnings” and “exercises”.

learnings: []
exercises: []

I would need something like what is mentioned in this post but for all files not for only a single one:

Also this topic is only working for one file:

E.g. trying the following dataview query is just a complete mess:

list file.frontmatter

as well as

list without id file.frontmatter

Maybe if you add group by file.name, but it would still be overwhelming.

You’d most likely be better of with some script which summarises the usage, but it’s likely to be loads of data anyways. I’m not able to attempt to write anything before tomorrow.

Why not a table…

TABLE file.frontmatter
WHERE file.frontmatter

… and spending some time reading the plugin documentation (if you want to use it). :slight_smile:

WHERE file.frontmatter gives you only cases where you have at least one field…

It’s after midnight, so I guess it’s tomorrow, and I built a script to list all fields from frontmatter.

The list all frontmatter fields script
// Store an alias for long function name
const listProp = Object.getOwnPropertyNames

// Get frontmatter from every page having one
const allMatter = 
    .where(p => listProp(p.file.frontmatter).length > 0)
// Loop all of the frontmatter, and count all fields
let fieldList = {}
for (let frontmatter of allMatter) {

  // For each frontmatter section, list and count each field
  for (let field of listProp(frontmatter)) {
    // console.log(field)
    if (field in fieldList) {
       fieldList[field] += 1
    } else {
       fieldList[field] = 1

// Build an ordinary array out of the dictionary
let fieldCounts = []
for (let key in fieldList) {
   fieldCounts.push([key, fieldList[key]])

// Sort the array for display purposes
fieldCounts = fieldCounts.sort((a, b) => a[1] - b[1])
// console.log(fieldCounts)

// Present the final table of all fields found in 
// frontmatter, with the most frequently used fields
// at the end of the table
dv.table(["name", "count"],
           .map(m => [m[0], m[1]])

This script does the following:

  • Store all frontmatter section from all notes having one into allMatter
  • Loop through allMatter and split into the separate fields, and store the count of these fields into fieldList (a dictionary object)
  • Build another array, fieldCount, based upon fieldList, and sort this according to the frequency of the field
  • Output fieldCount into av dv.table(), with the least frequent field names on the top, and the most used on the bottom

Review of fields table

Then one can review the table, and see if there are some fields one would want to eliminate or consolidate. To help localise the various fields, the following snippet would most likely be useful:

table file.frontmatter
where file.frontmatter and createddate

In the example above I’m listing the frontmatter with originating file for the field createddate, this of course you replace with whatever field you’re looking. If the field name has a space in it, replace with a dash/minus, aka Creation date becomes creation-date. The key name doesn’t depend on case.

Extra nugget: I’m so far not able to split up/flatten the file.frontmatter list of various fields in a DQL query. Are some of you up for that task?


This is incredibly helpful, Thank You!

1 Like

Holy moly, @holroy, this is exactly what I was looking for!
Thank you so very much. Works like a charm. :tada:
I’m so happy. :smile:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.