# MarkCodable - Markdown Codable repo

**URL:** <https://forums.swift.org/t/markcodable-markdown-codable-repo/60110>\
**Category:** Community Showcase\
**Tags:** codable, markdown\
**Created:** [September 5, 2022, 8:40pm UTC](https://forums.swift.org/t/markcodable-markdown-codable-repo/60110 "2022-09-05T20:40:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![icanzilb](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/icanzilb/32/20473_2.png) [@icanzilb](https://forums.swift.org/u/icanzilb)\
**Post date:** [September 5, 2022, 8:40pm UTC](https://forums.swift.org/t/markcodable-markdown-codable-repo/60110/1 "2022-09-05T20:40:12Z")

</div>

I just published [https://github.com/icanzilb/MarkCodable](https://github.com/icanzilb/MarkCodable).

It's a `Codable` implementation that encodes into Markdown text and decodes from Markdown.

For fairly simple data structures it offers a numbers of benefits over JSON:

- humans can view/edit the data in a plain text editor or online in a text field
- the data can be easily embedded in Swift code as a string and still be readable/editable
- tabular representation is easier to parse for humans than JSON

Here are some of the use cases in which you could use `MarkCodable`.

## Configuration files

Markdown is a viable alternative to json or yml files, especially for multiple configuration entries like per-environment or per-domain configurations, for example:

```plaintext
| environment | host | port | user | schema |
|-------------|-----------|------|------|--------|
| qa | 127.0.0.1 | 8080 | test | http |
| production | 2.317.1.2 | 9999 | app | https |

```

## Test and mock objects

In unit tests you often times need a number of test objects to create the test setup. Those are sometimes a bit clunky to always create in code so you can either include the Markdown in your tests or have it as an `.md` file in your test bundle:

```plaintext
| userID | name | age | permissions |
|--------|------|-----|-------------|
|1 |peter | 32 |read |
|2 |admin | 100 |read,write |

```

## Markdown-driven app backend

To show how easy it is to replace an app's backend with a markdown file hosted on github I also published this demo repo: [GitHub - MarkCodable/MarkCodableDemoApp: An app showcasing how to use markdown as an app backend](https://github.com/icanzilb/MarkCodingDemoApp)

Enjoy & let me know your feedback  
— Marin
