# Is it possible to auto generate motoko types from candid? Or to import candid directly to motoko somehow?

**URL:** <https://forum.dfinity.org/t/is-it-possible-to-auto-generate-motoko-types-from-candid-or-to-import-candid-directly-to-motoko-somehow/17555>\
**Category:** Developers\
**Created:** [December 19, 2022, 7:52pm UTC](https://forum.dfinity.org/t/is-it-possible-to-auto-generate-motoko-types-from-candid-or-to-import-candid-directly-to-motoko-somehow/17555 "2022-12-19T19:52:52Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![GLdev](https://avatars.discourse-cdn.com/v4/letter/g/4bbf92/32.png) [@GLdev](https://forum.dfinity.org/u/GLdev)\
**Post date:** [December 19, 2022, 9:04pm UTC](https://forum.dfinity.org/t/is-it-possible-to-auto-generate-motoko-types-from-candid-or-to-import-candid-directly-to-motoko-somehow/17555/2 "2022-12-19T21:04:01Z")

</div>

There’s a tool called [didc](https://forum.dfinity.org/t/didc-install-script/6140) that you can use.

```bash
$ cat first_project.did 
service : {
    "greet": (text) -> (text) query;
}

USAGE:
    didc bind <input> --target <target>

OPTIONS:
    -t, --target <target> Specifies target language [possible values: js, ts, did, mo,
                             rs]

$ didc bind first_project.did --target mo
// This is a generated Motoko binding.
// Please use `import service "ic:canister_id"` instead to call canisters on the IC if possible.

module { public type Self = actor { greet : shared query Text -> async Text } }

$ didc bind first_project.did --target rs
// This is an experimental feature to generate Rust binding from Candid.
// You may want to manually adjust some of the types.
use ic_cdk::export::candid::{self, CandidType, Deserialize};
use ic_cdk::api::call::CallResult;

struct SERVICE(candid::Principal);
impl SERVICE{
  pub async fn greet(&self, arg0: String) -> CallResult<(String,)> {
    ic_cdk::call(self.0, "greet", (arg0,)).await
  }
}

```

---

_[View the full topic](https://forum.dfinity.org/t/is-it-possible-to-auto-generate-motoko-types-from-candid-or-to-import-candid-directly-to-motoko-somehow/17555)._
