diff --git a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/operation/lsm/flush/FlushColumnMetadata.java b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/operation/lsm/flush/FlushColumnMetadata.java
index 2686204..f514638 100644
--- a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/operation/lsm/flush/FlushColumnMetadata.java
+++ b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/operation/lsm/flush/FlushColumnMetadata.java
@@ -47,7 +47,7 @@
 import org.apache.asterix.column.metadata.schema.visitor.SchemaBuilderFromIATypeVisitor;
 import org.apache.asterix.column.util.ColumnValuesUtil;
 import org.apache.asterix.column.util.RunLengthIntArray;
-import org.apache.asterix.column.util.SchemaStringBuilderVisitor;
+import org.apache.asterix.column.util.SchemaJSONBuilderVisitor;
 import org.apache.asterix.column.values.IColumnValuesWriter;
 import org.apache.asterix.column.values.IColumnValuesWriterFactory;
 import org.apache.asterix.column.values.writer.AbstractColumnValuesWriter;
@@ -582,12 +582,12 @@
             return;
         }
         // This should be a low frequency object creation
-        SchemaStringBuilderVisitor schemaBuilder = new SchemaStringBuilderVisitor(fieldNamesDictionary);
+        SchemaJSONBuilderVisitor schemaBuilder = new SchemaJSONBuilderVisitor(fieldNamesDictionary);
         String recordSchema = LogRedactionUtil.userData(schemaBuilder.build(root));
-        LOGGER.debug("Schema for {} has changed: \n {}", RECORD_SCHEMA, recordSchema);
+        LOGGER.debug("Schema for {} has changed: {}", RECORD_SCHEMA, recordSchema);
         if (metaRoot != null) {
             String metaRecordSchema = LogRedactionUtil.userData(schemaBuilder.build(metaRoot));
-            LOGGER.debug("Schema for {} has changed: \n {}", META_RECORD_SCHEMA, metaRecordSchema);
+            LOGGER.debug("Schema for {} has changed: {}", META_RECORD_SCHEMA, metaRecordSchema);
         }
     }
 }
diff --git a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/operation/query/QueryColumnMetadata.java b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/operation/query/QueryColumnMetadata.java
index 5028706..e507d53 100644
--- a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/operation/query/QueryColumnMetadata.java
+++ b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/operation/query/QueryColumnMetadata.java
@@ -46,7 +46,7 @@
 import org.apache.asterix.column.metadata.schema.AbstractSchemaNode;
 import org.apache.asterix.column.metadata.schema.ObjectSchemaNode;
 import org.apache.asterix.column.metadata.schema.visitor.SchemaClipperVisitor;
-import org.apache.asterix.column.util.SchemaStringBuilderVisitor;
+import org.apache.asterix.column.util.SchemaJSONBuilderVisitor;
 import org.apache.asterix.column.values.IColumnValuesReader;
 import org.apache.asterix.column.values.IColumnValuesReaderFactory;
 import org.apache.asterix.column.values.reader.PrimitiveColumnValuesReader;
@@ -273,9 +273,9 @@
     protected static void logSchema(String jobId, ObjectSchemaNode root, String schemaSource,
             IFieldNamesDictionary fieldNamesDictionary) throws HyracksDataException {
         if (jobId != null && LOGGER.isDebugEnabled() && System.nanoTime() % LOG_PROBABILITY == 0) {
-            SchemaStringBuilderVisitor schemaBuilder = new SchemaStringBuilderVisitor(fieldNamesDictionary);
+            SchemaJSONBuilderVisitor schemaBuilder = new SchemaJSONBuilderVisitor(fieldNamesDictionary);
             String schema = LogRedactionUtil.userData(schemaBuilder.build(root));
-            LOGGER.debug("Queried {} schema [{}]: \n {}", schemaSource, jobId, schema);
+            LOGGER.debug("Queried {} schema [{}]: {}", schemaSource, jobId, schema);
         }
     }
 }
diff --git a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/util/SchemaJSONBuilderVisitor.java b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/util/SchemaJSONBuilderVisitor.java
new file mode 100644
index 0000000..b425a26
--- /dev/null
+++ b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/util/SchemaJSONBuilderVisitor.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.column.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.asterix.column.metadata.IFieldNamesDictionary;
+import org.apache.asterix.column.metadata.schema.AbstractSchemaNode;
+import org.apache.asterix.column.metadata.schema.ISchemaNodeVisitor;
+import org.apache.asterix.column.metadata.schema.ObjectSchemaNode;
+import org.apache.asterix.column.metadata.schema.UnionSchemaNode;
+import org.apache.asterix.column.metadata.schema.collection.AbstractCollectionSchemaNode;
+import org.apache.asterix.column.metadata.schema.primitive.PrimitiveSchemaNode;
+import org.apache.asterix.dataflow.data.nontagged.serde.AStringSerializerDeserializer;
+import org.apache.asterix.om.base.AString;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.data.std.api.IValueReference;
+import org.apache.hyracks.data.std.util.ByteArrayAccessibleDataInputStream;
+import org.apache.hyracks.data.std.util.ByteArrayAccessibleInputStream;
+import org.apache.hyracks.util.string.UTF8StringReader;
+import org.apache.hyracks.util.string.UTF8StringWriter;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.IntNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.fasterxml.jackson.databind.node.TextNode;
+
+import it.unimi.dsi.fastutil.ints.IntList;
+
+public class SchemaJSONBuilderVisitor implements ISchemaNodeVisitor<JsonNode, Void> {
+    private static final String TYPE_FIELD = "type";
+    private static final String ITEM_FIELD = "item";
+    private static final String ITEMS_FIELD = "items";
+    private static final String FIELDS_FIELD = "fields";
+    private static final String INDEX_FIELD = "index";
+    private static final String LEVEL_FIELD = "level";
+    private static final String OBJECT_TYPE = "object";
+    private static final String ARRAY_TYPE = "array";
+    private static final String UNION_TYPE = "union";
+    private final List<String> fieldNames;
+    private int level;
+
+    public SchemaJSONBuilderVisitor(IFieldNamesDictionary dictionary) throws HyracksDataException {
+        this.fieldNames = new ArrayList<>();
+        AStringSerializerDeserializer stringSerDer =
+                new AStringSerializerDeserializer(new UTF8StringWriter(), new UTF8StringReader());
+        List<IValueReference> extractedFieldNames = dictionary.getFieldNames();
+        //Deserialize field names
+        ByteArrayAccessibleInputStream in = new ByteArrayAccessibleInputStream(new byte[0], 0, 0);
+        ByteArrayAccessibleDataInputStream dataIn = new ByteArrayAccessibleDataInputStream(in);
+        for (IValueReference serFieldName : extractedFieldNames) {
+            in.setContent(serFieldName.getByteArray(), 0, serFieldName.getLength());
+            AString fieldName = stringSerDer.deserialize(dataIn);
+            this.fieldNames.add(fieldName.getStringValue());
+        }
+        level = 0;
+    }
+
+    public String build(ObjectSchemaNode root) throws HyracksDataException {
+        JsonNode jsonNode = visit(root, null);
+        return jsonNode.toString();
+    }
+
+    @Override
+    public JsonNode visit(ObjectSchemaNode objectNode, Void arg) throws HyracksDataException {
+        List<AbstractSchemaNode> children = objectNode.getChildren();
+        IntList fieldNameIndexes = objectNode.getChildrenFieldNameIndexes();
+        ObjectNode jsonNode = JsonNodeFactory.instance.objectNode();
+        jsonNode.putIfAbsent(TYPE_FIELD, TextNode.valueOf(OBJECT_TYPE));
+        jsonNode.putIfAbsent(LEVEL_FIELD, IntNode.valueOf(level));
+        ObjectNode fieldsNode = JsonNodeFactory.instance.objectNode();
+        level++;
+        for (int i = 0; i < children.size(); i++) {
+            int index = fieldNameIndexes.getInt(i);
+            String fieldName = index < 0 ? "<empty>" : fieldNames.get(index);
+            AbstractSchemaNode child = children.get(i);
+            JsonNode childNode = child.accept(this, null);
+            fieldsNode.putIfAbsent(fieldName, childNode);
+        }
+        level--;
+        jsonNode.putIfAbsent(FIELDS_FIELD, fieldsNode);
+        return jsonNode;
+    }
+
+    @Override
+    public JsonNode visit(AbstractCollectionSchemaNode collectionNode, Void arg) throws HyracksDataException {
+        ObjectNode jsonNode = JsonNodeFactory.instance.objectNode();
+        jsonNode.putIfAbsent(TYPE_FIELD, TextNode.valueOf(ARRAY_TYPE));
+        jsonNode.putIfAbsent(LEVEL_FIELD, IntNode.valueOf(level));
+        AbstractSchemaNode itemNode = collectionNode.getItemNode();
+        level++;
+        jsonNode.putIfAbsent(ITEM_FIELD, itemNode.accept(this, null));
+        level--;
+        return jsonNode;
+    }
+
+    @Override
+    public JsonNode visit(UnionSchemaNode unionNode, Void arg) throws HyracksDataException {
+        ObjectNode jsonNode = JsonNodeFactory.instance.objectNode();
+        jsonNode.putIfAbsent(TYPE_FIELD, TextNode.valueOf(UNION_TYPE));
+        jsonNode.putIfAbsent(LEVEL_FIELD, IntNode.valueOf(level));
+        ArrayNode itemsNode = JsonNodeFactory.instance.arrayNode();
+        for (AbstractSchemaNode child : unionNode.getChildren().values()) {
+            itemsNode.add(child.accept(this, null));
+        }
+        jsonNode.putIfAbsent(ITEMS_FIELD, itemsNode);
+        return jsonNode;
+    }
+
+    @Override
+    public JsonNode visit(PrimitiveSchemaNode primitiveNode, Void arg) throws HyracksDataException {
+        ObjectNode jsonNode = JsonNodeFactory.instance.objectNode();
+        jsonNode.putIfAbsent(TYPE_FIELD, TextNode.valueOf(primitiveNode.getTypeTag().toString()));
+        jsonNode.putIfAbsent(LEVEL_FIELD, IntNode.valueOf(level));
+        jsonNode.putIfAbsent(INDEX_FIELD, IntNode.valueOf(primitiveNode.getColumnIndex()));
+        return jsonNode;
+    }
+
+}
