---
name: "desktoptojson"
section: "8"
platform: "linux"
package: "libkf5service-bin"
version: "5.116.0-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/desktoptojson"
---

# desktoptojson(8)

Converts a .desktop file to a .json file.

## NAME

desktoptojson - Converts a .desktop file to a .json file.

## SYNOPSIS

**desktoptojson** --input *DESKTOP-FILE* --output *JSON-FILE*

**desktoptojson** {--version \| --help}

## DESCRIPTION

The KService framework uses information contained in .desktop files to locate services, including plugins for Qt5-based applications and libraries. The Qt5 plugin system, however, uses JSON data embedded in the plugin itself. **desktoptojson** allows the information contained in a .desktop file to also be used as the embedded data for a Qt5 plugin by converting the .desktop file entries into JSON data.

The generated JSON data is a JSON object that maps the entries from the \[Desktop Entry\] group of the .desktop file. Any other groups are ignored. Most entries are just converted to JSON strings, but certain entries (such as Hidden and X-KDE-PluginInfo-EnabledByDefault) are known to be boolean values and converted as such, and similarly some (such as X-KDE-ServiceTypes and X-KDE-PluginInfo-Depends) are always converted to arrays of strings.

## OPTIONS

- **--input** *DESKTOP-FILE*

  The .desktop file to convert.

- **--output** *JSON-FILE*

  The file to write the generated JSON data to.

- **--help**

  Show a brief help text.

- **--version**

  Show version information.

## USAGE

Most users of this utility will use the CMake macro **kservice\_desktop\_to\_json** as part of the process of building a plugin.

```
add_library(myplugin MODULE ${myplugin_SRCS})
kservice_desktop_to_json(myplugin myplugin.desktop)
```

This will produce the JSON file myplugin.json, which can be referenced from the **K\_PLUGIN\_FACTORY\_WITH\_JSON** or **Q\_PLUGIN\_METADATA** macros.

## BUGS

Please use **KDE's bugtracker**\[1\] to report bugs.

## AUTHORS

**Scarlett Clark** \<scarlett@scarlettgatelyclark.com\>

Wrote the original documentation.

**Alex Merry** \<alexmerry@kde.org\>

Edited the documentation.

## NOTES

- 1\.

  KDE's bugtracker

  https://bugs.kde.org
