# Overview of all frontmatter fields used in vault

**URL:** <https://forum.obsidian.md/t/overview-of-all-frontmatter-fields-used-in-vault/49786>\
**Category:** Help\
**Tags:** yaml\
**Created:** [December 15, 2022, 8:58pm UTC](https://forum.obsidian.md/t/overview-of-all-frontmatter-fields-used-in-vault/49786 "2022-12-15T20:58:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![gibraltar](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/g/a4c791/32.png) [@gibraltar](https://forum.obsidian.md/u/gibraltar)\
**Post date:** [December 15, 2022, 8:58pm UTC](https://forum.obsidian.md/t/overview-of-all-frontmatter-fields-used-in-vault/49786/1 "2022-12-15T20:58:50Z")

</div>

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”.

```auto
---
title: {{title}}
date: {{date:YYYY-MM-DD}}
author:
source:
link:
---

```

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

```auto
---
learnings: []
exercises: []
---

```

---

<div class="post-metadata">

**Author:** ![gibraltar](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/g/a4c791/32.png) [@gibraltar](https://forum.obsidian.md/u/gibraltar)\
**Post date:** [December 15, 2022, 9:00pm UTC](https://forum.obsidian.md/t/overview-of-all-frontmatter-fields-used-in-vault/49786/2 "2022-12-15T21:00:29Z")

</div>

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

> [@How can I get a list of all the YAML fields from "Current File"?](https://forum.obsidian.md/t/how-can-i-get-a-list-of-all-the-yaml-fields-from-current-file/42474):
>
> Things I have tried I searched “list yaml by dataview” in help docs and [found an answer but that is listing all the YAML keywords my whole Vault](https://forum.obsidian.md/t/how-can-i-get-a-list-of-all-the-yaml-fields-i-have-defined-over-time-similar-to-tags-list/42391). I also tried: ```dataview list file.frontmatter from [[\<% tp.file.title %\>]]``` But this doesn’t show anything What I’m trying to do I have made a folder for habit tracking and everyday I make a page there that contains all the metadata in the YAML area that I use to make Heat Map Charts in other pages. What I want is that, to view all the metad…

---

<div class="post-metadata">

**Author:** ![gibraltar](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/g/a4c791/32.png) [@gibraltar](https://forum.obsidian.md/u/gibraltar)\
**Post date:** [December 15, 2022, 9:01pm UTC](https://forum.obsidian.md/t/overview-of-all-frontmatter-fields-used-in-vault/49786/3 "2022-12-15T21:01:19Z")

</div>

Also this topic is only working for one file:

> [@List all Metadata Created?](https://forum.obsidian.md/t/list-all-metadata-created/30864):
>
> Things I have tried As I tend to create metadata spontaneously inline (e.g. New Basic Field::Value), is there a dataview query to see all my fields? Sometimes I create a field within a note and then forget about it. What I’m trying to do

---

<div class="post-metadata">

**Author:** ![gibraltar](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/g/a4c791/32.png) [@gibraltar](https://forum.obsidian.md/u/gibraltar)\
**Post date:** [December 15, 2022, 9:08pm UTC](https://forum.obsidian.md/t/overview-of-all-frontmatter-fields-used-in-vault/49786/4 "2022-12-15T21:08:37Z")

</div>

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

```auto
list file.frontmatter

```

as well as

```auto
list without id file.frontmatter

```

---

<div class="post-metadata">

**Author:** ![holroy](https://forum.obsidian.md/user_avatar/forum.obsidian.md/holroy/32/77699_2.png) [@holroy](https://forum.obsidian.md/u/holroy)\
**Post date:** [December 15, 2022, 9:59pm UTC](https://forum.obsidian.md/t/overview-of-all-frontmatter-fields-used-in-vault/49786/5 "2022-12-15T21:59:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mnvwvnm](https://forum.obsidian.md/user_avatar/forum.obsidian.md/mnvwvnm/32/9766_2.png) [@mnvwvnm](https://forum.obsidian.md/u/mnvwvnm)\
**Post date:** [December 15, 2022, 10:06pm UTC](https://forum.obsidian.md/t/overview-of-all-frontmatter-fields-used-in-vault/49786/6 "2022-12-15T22:06:39Z")

</div>

Why not a table…

```sql
TABLE file.frontmatter
WHERE file.frontmatter

```

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

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

---

<div class="post-metadata">

**Author:** ![holroy](https://forum.obsidian.md/user_avatar/forum.obsidian.md/holroy/32/77699_2.png) [@holroy](https://forum.obsidian.md/u/holroy)\
**Post date:** [December 16, 2022, 12:13am UTC](https://forum.obsidian.md/t/overview-of-all-frontmatter-fields-used-in-vault/49786/7 "2022-12-16T00:13:57Z")

</div>

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**
>
> ````md
> ```dataviewjs
> // Store an alias for long function name
> const listProp = Object.getOwnPropertyNames
> 
> // Get frontmatter from every page having one
> const allMatter = 
> dv.pages()
> .where(p => listProp(p.file.frontmatter).length > 0)
> .file.frontmatter
>     
> // 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"],
> dv.array(fieldCounts)
> .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:

````auto
```dataview
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?

---

<div class="post-metadata">

**Author:** ![willasm](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/w/d26b3c/32.png) [@willasm](https://forum.obsidian.md/u/willasm)\
**Post date:** [December 16, 2022, 4:00am UTC](https://forum.obsidian.md/t/overview-of-all-frontmatter-fields-used-in-vault/49786/8 "2022-12-16T04:00:25Z")

</div>

This is incredibly helpful, Thank You!

---

<div class="post-metadata">

**Author:** ![gibraltar](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/g/a4c791/32.png) [@gibraltar](https://forum.obsidian.md/u/gibraltar)\
**Post date:** [December 16, 2022, 5:32pm UTC](https://forum.obsidian.md/t/overview-of-all-frontmatter-fields-used-in-vault/49786/9 "2022-12-16T17:32:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://forum.obsidian.md/uploads/default/original/3X/b/e/bec35fbd23ab28909bb6bfe62cb32eb82dd34019.png) [@system](https://forum.obsidian.md/u/system)\
**Post date:** [December 23, 2022, 5:32pm UTC](https://forum.obsidian.md/t/overview-of-all-frontmatter-fields-used-in-vault/49786/10 "2022-12-23T17:32:54Z")

</div>

Closed on December 23, 2022, 5:32pm UTC

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