Files.ListAsJSON
----------------

Queries list of file names in folder as JSON.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Files](component_Files.md) | [10.5](newinversion105.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Files.ListAsJSON"; Path { ; Keys; Filter; ExtensionFilter } ) 

**MBS**( **"Files.ListAsJSON";** /\* Queries list of file names in folder as JSON. \*/  
**$Path**; /\* Native path to the directory.e.g. "C:\\Test" \*/   
**$Keys**; /\* Optional; The keys to retrieve.  
Pass a list of values including Size, CreationTimeStamp, AccessTimeStamp, ModificationTimeStamp, Visible.  
Name, Directory and Type can be passed, but are always included.  
If keys is "All", we include all keys.  
Added IsApplication and IsPackage values for v13.5. \*/   
**$Filter**; /\* Optional; Optional, limits what is returned.   
Default is 0 to report all files.   
  
Pass a combination of the following values:  
1 for showing only files,   
2 for showing only directories and   
4 for showing only visible items.  
8 if the path includes the file name specification with wildcards.  
128 to use the extension filter text and do a substring match on the file name.  
  
e.g. pass 4+1 for visible files or 2+4 for visible directories.e.g. 5 \*/   
**$ExtensionFilter**) /\* Optional; Optional, a filter for getting only files with matching file extension.  
Since version 16.1 this can be a list.e.g. ".txt" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Path | Native path to the directory. | "C:\\Test" |  |
| Keys | The keys to retrieve.   Pass a list of values including Size, CreationTimeStamp, AccessTimeStamp, ModificationTimeStamp, Visible.   Name, Directory and Type can be passed, but are always included.   If keys is "All", we include all keys.   Added IsApplication and IsPackage values for v13.5. |  | Optional |
| Filter | Optional, limits what is returned.    Default is 0 to report all files.       Pass a combination of the following values:   1 for showing only files,    2 for showing only directories and    4 for showing only visible items.   8 if the path includes the file name specification with wildcards.   128 to use the extension filter text and do a substring match on the file name.      e.g. pass 4+1 for visible files or 2+4 for visible directories. | 5 | Optional |
| ExtensionFilter | Optional, a filter for getting only files with matching file extension.   Since version 16.1 this can be a list. | ".txt" | Optional |

### Result

Returns JSON array or error.

### Description

Queries list of file names in folder as JSON.  
This function needs a native path. Please use [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md) function in order to convert a FileMaker style path to a native path.  
  
With filter parameter being 8 on Windows, you can pass a path with wildcards directly and ExtensionFilter parameter is ignored. This is not supported on macOS.  
  
TimeStamps are returned in the FileMaker formatting. On Windows a key AlternateFileName may be included in result if the file has an alternative file name for DOS.  
If you need sorting, please check [JSON.SortWithEvaluate](JSONSortWithEvaluate.md) function.  
  
We can add more Keys if needed. Let us know if you need another value for all files.  
### Examples

List files on desktop:

 MBS ( "Files.ListAsJSON"; MBS ("[Folders.UserDesktop](FoldersUserDesktop.md)"); "Size¶CreationTimeStamp¶AccessTimeStamp¶ModificationTimeStamp¶Visible" )  
<small>  
Example result:   
\[ { "Name" : "Projects" , "Directory" : true, "Type" : "Directory" , "Visible" : true, "Size" : 64 , "CreationTimeStamp" : "28.09.2020 15:52" , "AccessTimeStamp" : "28.09.2020 15:51:58" , "ModificationTimeStamp" : "28.09.2020 15:51:58" } \] </small>List files and sort by name:

 MBS ( "[JSON.SortWithEvaluate](JSONSortWithEvaluate.md)";   
 MBS ( "Files.ListAsJSON";   
 MBS ("[Folders.UserDesktop](FoldersUserDesktop.md)");   
 "Size" );   
"JSONGetElement ( leftJSON; \\"Name\\") &lt; JSONGetElement ( rightJSON; \\"Name\\")" )  
List files and sort by size descending:

 MBS ( "[JSON.SortWithEvaluate](JSONSortWithEvaluate.md)";   
 MBS ( "Files.ListAsJSON";   
 MBS ("[Folders.UserDesktop](FoldersUserDesktop.md)");   
 "Size" );   
"JSONGetElement ( leftJSON; \\"Size\\") &gt; JSONGetElement ( rightJSON; \\"Size\\")" )  
List files and sort by modification time stamp:

 Let ( \[  
 path = MBS ("[Folders.UserDesktop](FoldersUserDesktop.md)");  
 list = MBS ( "Files.ListAsJSON"; path; "CreationTimeStamp¶ModificationTimeStamp" );  
 sort = MBS ( "[JSON.SortWithEvaluate](JSONSortWithEvaluate.md)"; list; "GetAsTimeStamp(JSONGetElement ( leftJSON; \\"ModificationTimeStamp\\")) &lt; GetAsTimeStamp(JSONGetElement ( rightJSON; \\"ModificationTimeStamp\\"))" )  
\];sort)  
List only text and RTF files on desktop:

 MBS ( "Files.ListAsJSON"; MBS ("[Folders.UserDesktop](FoldersUserDesktop.md)"); "Size¶CreationTimeStamp¶AccessTimeStamp¶ModificationTimeStamp¶Visible"; 4; ".txt¶.rtf" )  
<small>  
Example result:   
\[ { "Name" : "test.txt" , "Directory" : false, "Type" : "File" , "Visible" : true, "Size" : 75 , "CreationTimeStamp" : "24.02.2026 22:39:26" , "AccessTimeStamp" : "24.02.2026 22:39:28" , "ModificationTimeStamp" : "24.02.2026 22:39:22" }, { "Name" : "test.rtf" , "Directory" : false, "Type" : "File" , "Visible" : true, "Size" : 220 , "CreationTimeStamp" : "24.02.2026 22:39:23" , "AccessTimeStamp" : "24.02.2026 22:39:19" , "ModificationTimeStamp" : "24.02.2026 22:39:19" } \] </small>### See also

- [Files.List](FilesList.md)
- [Folders.UserDesktop](FoldersUserDesktop.md)
- [JSON.Sort](JSONSort.md)
- [JSON.SortWithEvaluate](JSONSortWithEvaluate.md)
- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)

### Release notes

- **Version 16.1**
    - Changed [Files.List](https://www.mbsplugins.eu/FilesList.shtml), [Files.ListAsJSON](https://www.mbsplugins.eu/FilesListAsJSON.shtml) and [Files.ListRecursive](https://www.mbsplugins.eu/FilesListRecursive.shtml) to accept a list for ExtensionFilter parameter.
- **Version 15.2**
    - Added flag 128 for matching substring with the ExtensionFilter parameter for the [Files.List](https://www.mbsplugins.eu/FilesList.shtml), [Files.ListAsJSON](https://www.mbsplugins.eu/FilesListAsJSON.shtml) and [Files.ListRecursive](https://www.mbsplugins.eu/FilesListRecursive.shtml) functions.
- **Version 13.5**
    - Added IsApplication and IsPackage for [Files.ListAsJSON](https://www.mbsplugins.eu/FilesListAsJSON.shtml) function.
    - Fixed [Files.ListAsJSON](https://www.mbsplugins.eu/FilesListAsJSON.shtml) function to not filter invisible files on macOS without asked to do that.
- **Version 11.5**
    - Fixed [Files.ListAsJSON](https://www.mbsplugins.eu/FilesListAsJSON.shtml) to query date and size of a symlink instead of the target.
- **Version 10.5**
    - Added [Files.ListAsJSON](https://www.mbsplugins.eu/FilesListAsJSON.shtml) function to list files and return it as JSON.

### Blog Entries

- [MBS FileMaker Plugin, version 16.1pr5](https://www.mbsplugins.de/archive/2026-03-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 15.2pr1](https://www.mbsplugins.de/archive/2025-04-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin Advent calendar: 12 - Files](https://www.mbsplugins.de/archive/2023-12-12/MBS_Plugin_Advent_calendar_12_/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 13.5pr7](https://www.mbsplugins.de/archive/2023-11-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 13.5pr6](https://www.mbsplugins.de/archive/2023-10-26/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 11.5pr7](https://www.mbsplugins.de/archive/2021-11-13/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [New in MBS FileMaker Plugin 10.5](https://www.mbsplugins.de/archive/2020-11-23/New_in_MBS_FileMaker_Plugin_10/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 10.5 - More than 6400 Functions In One Plugin](https://www.mbsplugins.de/archive/2020-11-17/MBS_FileMaker_Plugin_105_-_Mor/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 10.5pr1](https://www.mbsplugins.de/archive/2020-10-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Embrace JSON](https://www.mbsplugins.de/archive/2020-09-29/Embrace_JSON/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 6/2020, Seite 26](https://filemaker-magazin.de/neuigkeit/4118-Appetithappen-FMM_202006)

This function checks for a license.

Created 28th September 2020 , last changed 9th March 2026

  
[Files.List](FilesList.md) - [Files.ListOpenFiles](FilesListOpenFiles.md)

[HTML Version](FilesListAsJSON.shtml)