Uncaught SyntaxError: Unexpected token } in JSON at position 33

Specifically, this line inside page's html is causing the error:

<script type="text/x-magento-init">{"*": {"Magento_Ui/js/core/app": }}</script>

"Magento_Ui/js/core/app" doesn't have a value.

I've already cleared all the exceptions on the front-end relating to xml configuration.

Can somebody point me the right direction? I'm still discovering new Magento2 AJAX request flow.


the problem was cause by a single module. Removing its settings from core_config_data and clearing the cache fixed the problem - the settings were regenerated.

  • Can you tell us which one made that error please?
    – Aurélien
    Commented Mar 11, 2018 at 20:03
  • @Aurélien I don't remember the name now because I have disabled several modules at that time and I don't want to guess. The problem was that I removed the module files but left database entry so Magento saw it as enabled.
    – Alan
    Commented Mar 12, 2018 at 19:52

1 Answer 1


This bug related to error during json_encode in \Magento\Ui\TemplateEngine\Xhtml\Result::appendLayoutConfiguration method, in my case error was 'Malformed UTF-8 characters, possibly incorrectly encoded'. I used json_last_error_msg() to get it.

My solution is to create plugin for appendLayoutConfiguration() function:

public function aroundAppendLayoutConfiguration(
    \Magento\Ui\TemplateEngine\Xhtml\Result $result,
    \Closure $closure
) {
    $layoutConfiguration = $this->wrapContent(json_encode($this->utf8ize($this->structure->generate($this->component))));

Here is utf8ize() function:

 * @param $data
 * @return array|string
public function utf8ize($data) {
    if (is_array($data))
        foreach ($data as $key => $value)
            $data[$key] = $this->utf8ize($value);

    else if(is_object($data))
        foreach ($data as $key => $value)
            $data->$key = $this->utf8ize($value);

        return utf8_encode($data);

    return $data;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.